Excluding certain properties when asserting objects with FluentAssertion

It’s very common that we assert if two objects are equivalent in unit tests. Using FluentAssertion, this looks like the following

However, there are times where you want to exclude certain properties when comparing objects. This might be because the value of the property cannot be predicted or you just don’t want to include … [Read more…]

Organising unit tests into partial classes

When unit testing a service, I tend to have a base class where I do all the setting up/initialisation. For each method in the service, I’d have a separate unit test class which derives from the base class. For example, if I want to unit test two methods GetAllNews and GetNewsById in SampleNewsService, I’ll have a SampleNewsServiceTestsBase … [Read more…]