【发布时间】:2010-11-25 09:35:54
【问题描述】:
我在以下代码段中有两个相同的字节数组:
/// <summary>
///A test for Bytes
///</summary>
[TestMethod()]
public void BytesTest() {
byte[] bytes = Encoding.UTF8.GetBytes(Properties.Resources.ExpectedPacketData);
TransferEventArgs target = new TransferEventArgs(bytes);
byte[] expected = Encoding.UTF8.GetBytes(Properties.Resources.ExpectedPacketValue);
byte[] actual;
actual = target.Bytes;
Assert.AreEqual(expected, actual);
}
两个数组的字节完全相同。在这种情况下,为什么 Assert.AreEqual 会失败?
【问题讨论】:
-
请注意,如果您使用 NUnit,则从 2.2 版本开始支持数组的值比较,因此
Assert.AreEqual可以正常工作。
标签: c# unit-testing assert