我很新,可以编组,XUnit和Newtonsoft。 Json. 在我试图比较使用Ausert两种不同的JOject。 单位测试中的平等()方法,通过,参见以下实例代码:
using Newtonsoft.Json.Linq;
namespace TestProject1
{
public class UnitTest1
{
[Fact]
public void Test1()
{
JObject jobj1 = JObject.FromObject(new { foo = "bar" });
JObject jobj2 = JObject.FromObject(new { foo = 1 });
JObject jobj3 = JObject.FromObject(new { foo = "b" });
Assert.Equal(jobj1, jobj2); // output: pass
Assert.Equal(jobj1, jobj3); // output: failure
Assert.True(jobj1.Equals(jobj2)); // output: failure
Assert.True(jobj1.Equals(jobj3)); // output: failure
}
}
}
I don t quite understand how this happens, should I look deep into xUnit or Newtonsoft.Json?
I find there is a DeepEquals method from Newtonsoft.Json, but I am not sure which comparator does xUnit call.