[英]Equality of two objects in NUnit
I am currently trying to test that two C# objects are the same (not referencing the same object, but have the same values). 我目前正在尝试测试两个C#对象是否相同(不引用相同的对象,但是具有相同的值)。 Trying to use Assert.Equals gives me "Assert.Equals should not be used for Assertions".
尝试使用Assert.Equals会给我“ Assert.Equals不应用于断言”。 What should I use ?
我应该使用什么?
Use Asset.AreEqual
. 使用
Asset.AreEqual
。
The Asset
class is a child of the object
class (like any class in C#) and when you call Asset.Equals
you are actually calling the method object.Equals
which is not what you want to do. 该
Asset
类是的子object
类(如在C#中的任何类),当你调用Asset.Equals
你实际上是调用该方法object.Equals
这是不是你想要做什么。
Programmers of NUnit probably put an exception in Asset.Equals
to prevent people from making the mistake of using the wrong equality method. NUnit的程序员可能在
Asset.Equals
放置了一个异常Asset.Equals
可以防止人们由于使用错误的相等方法而犯错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.