MVC Testing using a mocking framework (Moq)
问题 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