Diff between Assert.AreEqual and Assert.AreSame?

前端 未结 2 420
孤独总比滥情好
孤独总比滥情好 2021-02-02 04:45

What is the difference between Assert.AreEqual and Assert.AreSame?

2条回答
  •  不思量自难忘°
    2021-02-02 05:40

    Assert.AreEqual(a, b) is the same as Assert.IsTrue(Object.Equals(a, b))

    Assert.AreSame(a, b) is the same as Assert.IsTrue(Object.ReferenceEquals(a, b))

    (the only reason I knew is I just figured it out myself a few hours ago today because I needed to do a Assert.IsTrue(Object.ReferenceEquals(a,b)) and thought "I wonder if there is a better way to do this")

提交回复
热议问题