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
There are NuGet packages that do this for you. Here are two examples that I personally use.
DeepEqual:
object1.ShouldDeepEqual(object2);
ExpectedObjects:
[Fact]
public void RetrievingACustomer_ShouldReturnTheExpectedCustomer()
{
// Arrange
var expectedCustomer = new Customer
{
FirstName = "Silence",
LastName = "Dogood",
Address = new Address
{
AddressLineOne = "The New-England Courant",
AddressLineTwo = "3 Queen Street",
City = "Boston",
State = "MA",
PostalCode = "02114"
}
}.ToExpectedObject();
// Act
var actualCustomer = new CustomerService().GetCustomerByName("Silence", "Dogood");
// Assert
expectedCustomer.ShouldEqual(actualCustomer);
}