我对这一切还很陌生,因此我们将不胜感激。
我已经从url方法创建了一个下载图像,我需要对其进行测试。
我尝试填写测试参数,但不确定要输入的内容。
你能告诉我去哪里意味着什么吗,
谢谢。
亚伦
[TestMethod()]
public void DownloadImageFromURLTest()
{
string url = "http://www.omnimedicalsearch.com/conditions-diseases/images/skin-mole.jpg";
Image expected = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\skin-mole.jpg");
Image actual = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\skin-mole.jpg"); ;
actual = CloudConnection.DownloadImageFromURL(url);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
最佳答案
尝试这个:
string url = "http://www.omnimedicalsearch.com/conditions-diseases/images/skin-mole.jpg";
Image expected = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\skin-mole.jpg");
Image actual = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\skin-mole.jpg"); ;
actual = CloudConnection.DownloadImageFromURL(url);
MemoryStream ms = new MemoryStream();
expected.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
String expectedBitmap = Convert.ToBase64String(ms.ToArray());
ms.Position = 0;
actual.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
String actualBitmap = Convert.ToBase64String(ms.ToArray());
Assert.AreEqual(expectedBitmap, actualBitmap);
关于c# - Assert.AreEqual失败,错误C#,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8383731/