XUnit Assertion for checking equality of objects

后端 未结 5 868
小蘑菇
小蘑菇 2021-02-03 19:11

I am using XUnit framework to test my C# code.

Is there any assert method available in this framework which does the object comparison? My intention is to check for equa

5条回答
  •  灰色年华
    2021-02-03 19:40

    FluentAssertions library has some pretty powerful comparison logic inside.

    myObject.ShouldBeEquivalentTo(new { SomeProperty = "abc", SomeOtherProperty = 23 });
    

    You can even use this to assert on part of "myObject". However, it might not help you with the private fields.

提交回复
热议问题