-
Notifications
You must be signed in to change notification settings - Fork 733
Closed
Labels
Description
Suppose that I have an entity class Order and a DTO class OrderDto like this :
class Order
{
public long Id { get; set; }
public DateTime Date { get; set; }
public int State { get; set; }
}
class OrderDto
{
public long Id { get; set; }
public DateTime Date { get; set; }
public StateDto State { get; set; }
}
class StateDto
{
public int Code { get; set; }
public String Text { get; set; }
}Now, I have a test where I want to verify that a retrieved DTO is equivalent to existing entity.
Order existing;
OrderDto actual;
// Arrange
existing = ....;
// Act
actual = ....;
// Assert
actual.ShouldBeEquivalentTo(existing);This assertion fails because there is no State.Code and State.Text properties in the Order class.
So I changed my assertion to :
actual.ShouldBeEquivalentTo(existing, o => o.ExcludingMissingMembers());Now it works but it does not assert that the State.Code nested property of the OrderDto class is equal to the State property of the Order class.
So my test is not complete.
What would be the best way to assert the state code of the retrieved DTO ? (I have other similar properties in the DTO class).
Deilan, tparikka, zordark, peflorencio, joaopgrassi and 6 morexzxzxc and danielhdezller