Why does Assert.AreEqual(T obj1, Tobj2) fail with identical byte arrays

前端 未结 6 2009
日久生厌
日久生厌 2021-02-03 16:56

I have two identical byte arrays in the following segment of code:

    /// 
    ///A test for Bytes
    ///
    [TestMethod()]
            


        
6条回答
  •  失恋的感觉
    2021-02-03 17:02

    The method Assert.AreEqual under the hood will end up defaulting to Object.Equals() for non-null values. The default implementation of Object.Equals() is referential equality. The 2 arrays are identical value wise but difference reference wise and hence will not be considered equal.

提交回复
热议问题