Nyami

Something interesting for sure...

Verifying calls with NSubstitute

This one came up recently so I thought I would do a post for my future self, so I have something to come back to. Being a conscientious developer 1 I was creating unit tests and I found a situation where I wanted to verify the call to a method was the expected call, in this case the functionality being tested was creating an object and then calling a repository to persist this, I needed to check the object being persisted was as I expected.

Read more...

Solution Wide Project Settings

When working with larger solutions in Visual Studio there often common properties you want to set across the board for all your project, for example Copyright or TreatWarningsAsErrors. It can be a little tedious to set these for all the projects, particularly for bigger solutions, and when you add new projects to your solution it's easily missed resulting in undesired differences between projects. A nice simple way to set common properties is to use Directory.Build.props.

Read more...

Entity Builder for Unit Tests

If you find yourself needing to create an instance of a domain entity for unit testing, but having trouble getting round property or constructor accessability, using a builder is a great technique to get round this and provide a consistent, reusable method of creating the object for your tests.

Read more...