Reputation: 39524
I have the following class:
public class OrderRule {
public OrderDirection Direction { get; }
public String Property { get; }
}
I created an Unit Test using XUnit as follows:
public void TryParse_ParseAscendingOrderRule() {
OrderRule expect = new OrderRule("name", OrderDirection.Ascending);
OrderRule result = factory.GetOrderRule("type1");
Assert.Equal(result, expect);
}
I know expect and result have the same Direction and Property values but I still get False on my test ... I suppose this is because they are not the same instance ...
Do I really need to compare the Direction and Property as follows?
Assert.True(result.Property == expect.Property && expect.Property == expect.Property );
This can become really long when the objects have many properties ...
Or is there a better way to do this?
Upvotes: 0
Views: 181