Mock HttpContext.Current in Test Init Method
I’m trying to add unit testing to an ASP.NET MVC application I have built. In my unit tests I use the following code: [TestMethod] public void IndexAction_Should_Return_View() { var controller = new MembershipController(); controller.SetFakeControllerContext(“TestUser”); … } With the following helpers to mock the controller context: public static class FakeControllerContext { public static HttpContextBase FakeHttpContext(string username) … Read more