Hi
I'm using Moq to help in testing my ASP.NET MVC2 application.
Problem: ArgumentException was unhandled by user code. Unable to obtain public key for StrongNameKeyPair
This code has been adapted from Scott Hanselman's NerdDinner1.
HomeController CreateHomeControllerAs(string userName)
{
var mock = new Mock<ControllerContext>();
mock.SetupGet(p => p.HttpContext.User.Identity.Name).Returns(userName); // fails here
mock.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
var controller = new HomeController();
controller.ControllerContext = mock.Object;
return controller;
}
[TestMethod]
public void should_be_able_to_get_to_index_page_logged_in()
{
HomeController controller = CreateHomeControllerAs("dave");
}
Using Moq referenced... VS2010 under WinXP.