tips

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...

dotnet sln add

It's been a while since I'd created a number dotnet projects and supporting solution using the command line so I had to refer to the documentation to keep me right. As I had just created a number of projects adding each one to the solution is a little tedious so when I'd spotted I could use globbing patterns I thought this would save time and a few key presses.

Read more...

Simple ping Middleware

If you find yourself needing to create a simple ping endpoint often used by load balancers as a quick check to see if traffic can be directed to your site, rather than complicating the simple and creating an MVC controller etc consider simple middleware.

Read more...

Creating a Self-Signed Certificate for Identity Provider

I’d recently had to create a self-signed certificate for use in IdentityProvider4 and was coming up against problems when using the default options with New-SelfSignedCertificate PS module.

Identity Server was throwing "CryptographicException: Invalid provider type specified" and I had ensured the user account had access so it should have been all good. After a little bit of digging it turned out the private keys were not accessible from .NET. David Christiansen’s blog post helped me track down the issue but with a little more research I ended up with the following PowerShell to create a working certificate avoiding additional steps I didnt understand ;).

Read more...

RadButton Single Click

A great and easy way to avoid the double-bounce issue and prevent getting duplicate entries etc is to use the SingleClick property of the RadButton.

Read more...