Prevent ‘Automatic HTTP 400 responses’ for and individual controller action

ASP.NET Core 2.1 introduces a nice feature called Automatic HTTP 400 responses which means you don't need to put the following in the start of each controller action: if (!ModelState.IsValid) { return BadRequest(ModelState); } That was working out well for me until I didn't want it to happen for one of my actions. I wanted to do … Continue reading Prevent ‘Automatic HTTP 400 responses’ for and individual controller action

Failed to create the imposter with port 4555 and protocol http.

If you've ever had the following error when running tests using MbDotNet  / mountebank it can be quite frustrating. { "errors": [ { "code": "resource conflict", "message": "Port 4555 is already in use" } ] } It probably means something has not bee disposed of properly when a test has failed i.e. the imposters or … Continue reading Failed to create the imposter with port 4555 and protocol http.

Converting VSTS build definitions to YAML

Visual Studio Team System (VSTS) has a new feature in preview to allow builds to be defined in code and therefore in source control. I'm not going to try to explain the why or how to do this. These blog posts already do a great job of that: https://blog.kloud.com.au/2017/11/26/vsts-build-definitions-as-yaml-part-1-what-and-why/ https://blog.kloud.com.au/2017/11/26/vsts-build-definitions-as-yaml-part-2-how/ I just want to talk … Continue reading Converting VSTS build definitions to YAML

Set up unit testing with xUnit in .NET Core

A quick post on getting going with xUnit in .NET Core. Create a .NET Core Class Library. Open a command prompt and cd to your project folder. Add the following nuget packages: dotnet add package Microsoft.NET.Test.Sdk dotnet add package xunit dotnet add package xunit.runner.visualstudio Add a test to your test class e.g. Hopefully this help … Continue reading Set up unit testing with xUnit in .NET Core

Stubbing REST services with Mountebank / MbDoNet

What is it? Mountebank is an open source project that provides test doubles over multiple protocols i.e. http, https, tcp, smtp. MbDotNet is a .NET client library for interacting with Mountebank. Why? So why would you want to use Mountebank? The cases I am going to describe are when testing code that uses REST services. The purpose of Mountebank is … Continue reading Stubbing REST services with Mountebank / MbDoNet