Mocking HttpContext with Fake It Easy
Lets start with the conclusion first and say “use Nancy for your web applications and APIs” as its brilliant!
If you want to continue reading lets crack on.
I’m currently working on a ASP.Net MVC project and one of the controller methods writes directly to the Response, eg. Response.Write(“How will I mock thee?”);
Having moved over to xUnit and FakeItEasy recently I wanted to write a unit or integration test depending how you see it to assert against the Http Response.
Doing this is no easy feat with MVC (with Nancy its all done for you) and you have to mock a lot of things. I’m hoping that in later releases this will be fixed because I know that ASP.Net Web API has made things a bit easier for testing (and wrote a testing library for it) so I assume the two projects will use bits of each other or their roadmap will merge.
I found that there a quite a lot of samples with Moq but nothing for Fake It Easy(FIE) so I checked in at the FIE [...Read More...]

…Read More…]