A common unit test assert I need to do is compare all the property values of one object to another. For example:
[Test]
public void TestSaveWorks()
{
// Create a value to save.
var expectedDto = new SomeDto() {ValueOne = 1, ValueTwo = "Blah"};
// Save the value.
_someDbService.Save(dtoToSave);
// Load the value from the database. The DTO ID
// should have been set by the save.
var actualDto = _someDbService.Find(expectedDto.Id);
Assert.That(expectedDto.ValueOne, Is.EqualTo(actualDto.ValueOne));
Assert.That(expectedDto.ValueTwo, Is.EqualTo(actualDto.ValueTwo));
}
In this test we only have two properties to test but if the object has 10 plus properties to test that would be quite onerous. I often forget to update the tests after I add a new property to the object.
[Read More]

