gpt4 book ai didi

c# - Assert.AreEqual 失败错误 C#

转载 作者:太空宇宙 更新时间:2023-11-03 22:06:10 24 4
gpt4 key购买 nike

我对这一切都很陌生,所以任何帮助都将不胜感激。

我已经从 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com