Mis*_*sky 14
如果我理解正确,您可以使用DeepEqualNuGet 包,然后在代码中:
actualObject.ShouldDeepEqual(expectedObject);
Run Code Online (Sandbox Code Playgroud)
另一种选择是使用FluentAssertionsNuGet 包,然后在代码中:
actualObject.Should().BeEquivalentTo(expectedObject);
Run Code Online (Sandbox Code Playgroud)
public static bool IsEqual(this object obj, object another)
{
if (ReferenceEquals(obj, another)) return true;
if ((obj == null) || (another == null)) return false;
if (obj.GetType() != another.GetType()) return false;
var objJson = JsonConvert.SerializeObject(obj);
var anotherJson = JsonConvert.SerializeObject(another);
return objJson == anotherJson;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
180 次 |
| 最近记录: |