TDD


Mocking a ControllerContext with authenticated user with Moq for ASP.NET MVC (3)

Whenever you are writing unit tests or BDD-style specs for your ASP.NET MVC controllers (you are, right?) there will come a moment when you actually need to simulate that a user is authenticated to your site. Even if you’re familiar with mocking, letting the controller think someone has logged in t ...

Using dynamic to unit test an Action Method that returns JsonResult with MVC 3 and C# 4

We’ve all been there, haven’t we? We have an action method that we call through Ajax.ActionLink, Ajax.BeginForm or even with jQuery.ajax, and returning a JsonResult is what makes the most sense. But whatever you pass to a  JsonResult only gets exposed through the JsonResult.Data property which, ...