How to Compare two objects in unit test?

前端 未结 15 1709
自闭症患者
自闭症患者 2020-11-30 03:15
public class Student
{
    public string Name { get; set; }
    public int ID { get; set; }
}

...

var st1 = new Student
{
    ID =          


        
15条回答
  •  臣服心动
    2020-11-30 03:31

    It looked liked AutoFixture's Likeness is what I needed for this problem (thanks Mark Seeman) however it does not support comparing collection elements for likeness (there's a couple open issues on the matter but they have not been resolved).

    I found CompareObjects by Kellerman Software does the trick:

    https://github.com/GregFinzer/Compare-Net-Objects

提交回复
热议问题