Ngu*_*ong 1 c# asp.net-mvc nunit unit-testing fluent-assertions
我目前正在使用FluentAssertion比较 2 个对象。
我很想知道它是用什么方式来比较的?
\n\n使用Reflection像这样
public static void PropertyValuesAreEquals(object actual, object expected) \n{\n PropertyInfo[] properties = expected.GetType().GetProperties();\n foreach (PropertyInfo property in properties)\n {\n object expectedValue = property.GetValue(expected, null);\n object actualValue = property.GetValue(actual, null);\n if (!Equals(expectedValue, actualValue))\n Assert.Fail("Property {0}.{1} does not match. Expected: {2} but was: {3}", property.DeclaringType.Name, property.Name, expectedValue, actualValue);\n //\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6.\n}\nRun Code Online (Sandbox Code Playgroud)\n\n如果用另一种方式来比较,那是什么呢?
\n| 归档时间: |
|
| 查看次数: |
13593 次 |
| 最近记录: |