NUnit - 断言检查所有属性是否相等? [英] NUnit - Assert to check all properties are equal?
本文介绍了NUnit - 断言检查所有属性是否相等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Nunit 中是否有一个断言可以检查 2 个对象之间的所有属性是否相同,而我不必覆盖 Equals?
Is there an assertion built into Nunit that checks all properties between 2 objects are the same, without me having to override Equals?
我目前正在使用反射来断言一对对象的每个单独的属性.
I'm currently using reflection to Assert each individual property for a pair of objects.
推荐答案
我不相信有.
Assert.AreEqual 通过 Equals 比较非数字类型.
Assert.AreSame 检查它们是否指向同一个对象
Assert.AreEqual compares non-numeric types by Equals.
Assert.AreSame checks if they refer to the same object
这篇关于NUnit - 断言检查所有属性是否相等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文