public class Student
{
public string Name { get; set; }
public int ID { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
...
var st1 = new Student
{
ID = 20,
Name = "ligaoren",
};
var st2 = new Student
{
ID = 20,
Name = "ligaoren",
};
Assert.AreEqual<Student>(st1, st2);// How to Compare two object in Unit test?
Run Code Online (Sandbox Code Playgroud)
如何比较Unitest中的两个集合?
我试图发现两个JSON字符串是否相等.
这是我之前尝试过的
var obj1 = Json.Decode("{\"ValueA\":1,\"ValueB\":2}")
var obj2 = Json.Decode("{\"ValueB\":2,\"ValueA\":1}")
// But then there seems to be no way to compare the two objects?
Run Code Online (Sandbox Code Playgroud)
当然,必须存在一种优雅简单的方式来实现我认为的常见任务?