Tôi có hai mảng byte giống hệt nhau trong phân khúc mã sau đây:Tại sao Assert.AreEqual (T obj1, Tobj2) thất bại với mảng byte giống hệt
/// <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);
}
Cả hai mảng là giống hệt nhau xuống byte rất. Trong kịch bản này, tại sao Assert.AreEqual lại thất bại?
Là một lưu ý, nếu bạn sử dụng NUnit, so sánh giá trị của mảng được hỗ trợ từ phiên bản 2.2, vì vậy 'Assert.AreEqual' sẽ hoạt động tốt. –