Mocking DependencyResolver

This may be known to some of you, but I’d never had to do this before, so I thought I’d share. I had some MVC 4 code that explicitly calls the System DependencyResolver (the application uses Unity for dependency injection) to retrieve a service: https://gist.github.com/williamhallatt/751e26ee1ed64b51ea1648eff776c56a Mocking (in this case) the ISomeOtherService is obviously a trivial matter … Continue reading Mocking DependencyResolver

Adding Docker Terminal to cmder on Windows

I've recently started playing with Docker on Windows 10 and, as an avid supporter of the cmder console emulator, I obviously prefer having all my console options in one place. A couple of things to note before we start: My Docker installation directory is I go under the assumption that you already have git for Windows installed somewhere on … Continue reading Adding Docker Terminal to cmder on Windows

Mocking multipart/form-data HttpRequestMessage for testing ASP.NET ApiController

I recently had a problem where I needed to unit test an ApiController action that read data off of the controller’s request object, in other words, something that looks like this: https://gist.github.com/williamhallatt/c66ace1c849d9b52696b5f121481f1ad The real-world action receives a multipart/form-data request (a form), which contains an uploaded file as one of its fields. Reading the form fields and … Continue reading Mocking multipart/form-data HttpRequestMessage for testing ASP.NET ApiController

Uncrustify, Windows Shell Script and Visual Studio Build Events

If you're here, you probably know this already, but Uncrustify is a "code beautifier" with 454 configurable options at the time of writing (in short, you can pretty much set up any any code style convention you can imagine). Since I am a massive supporter of "anything that can be automated should be automated" I decided … Continue reading Uncrustify, Windows Shell Script and Visual Studio Build Events