Acceptable Dependencies

Today I attended a talk about mocking in order to facilitate unit testing. The example used was a “UsersService” that accepted a repository as a constructor argument. Essentially it was doing CRUD and forwarding the calls almost straight on to the repository: The interesting part was when we got to testing “Create“. The problem is […]

Testing asynchronous JavaScript

By making AJAX┬ácalls directly to the server from your JavaScript view-model it can be impossible to get the code under test. A simple solution is to fake the calls and make them synchronous. This example view-model for a library takes a function that will make a call to the server to check out a book […]

The trouble with shims

Shims are described in Michael Feather’s book on legacy code as a stepping stone on the path to dependency inversion – they are a technique for breaking apart untestable code. Visual Studio 2012 ships with some libraries that are able to magically intercept and manipulate calls to code that are normally untouchable – even .NET […]