C#-RestSharp-GET-Assert图像png
我使用RestSharp创建了一个API测试,用于测试自动化 我想创建一个测试,在这个测试中我断言了这一点,并从响应中的get请求中获得了正确的映像C#-RestSharp-GET-Assert图像png,c#,asp.net,api,automation,restsharp,C#,Asp.net,Api,Automation,Restsharp,我使用RestSharp创建了一个API测试,用于测试自动化 我想创建一个测试,在这个测试中我断言了这一点,并从响应中的get请求中获得了正确的映像 client = new RestClient(ConfigurationHelper.GetValue("BaseURL")); client.Authenticator = new NtlmAuthenticator((Domain + User), Password); request = new RestRequest(
client = new RestClient(ConfigurationHelper.GetValue("BaseURL"));
client.Authenticator = new NtlmAuthenticator((Domain + User), Password);
request = new RestRequest(EndPoint, Method.GET);
IRestResponse restResponse = await client.ExecuteAsync(request);
var response = restResponse.Content;
但是,当我在最后一行设置断点时,响应内容显示为字符串
我怎样才能正确地断言这一点?或者是否有更好的方法发送GET请求并将响应断言为图像这是对您问题的回答
但我会稍微修改一下您的测试:
不使用ExecuteAsync,而是使用DownloadData获取文件的字节。然后可以断言生成的文件哈希值相等。不使用ExecuteAsync,而是使用DownloadData获取文件的字节。然后可以断言生成的文件哈希值相等。
request = new RestRequest(EndPoint, Method.GET);
byte[] restResponse = client.DownloadData(request);