我正在尝试使用 Moq 来模拟 MembershipProvider。我收到以下错误
{"访问路径'C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO 11.0\
我猜我没有正确地嘲笑 MembershipProvider。通常我会做一个 mock.Object() 来获取新的模拟对象,但我不确定如何处理我的模拟 MembershipProvider。
[TestMethod]
public void LogUserIntoSystem_post_CorrectUsernameAndPassword()
{
var model = new LoginModel
{
LoginName = "Bobby",
Password = "bob",
RememberMe = true
};
var membership = new Mock<MembershipProvider>();
membership.Setup(x => x.ValidateUser("Bobby", "bob")).Returns(true);
var controllerUnderTest = _testModel.ReturnController();
//act
controllerUnderTest.Login(model, string.Empty);
//assert
var actionResult = (RedirectToRouteResult)controllerUnderTest.Home();
Assert.AreEqual("Home", actionResult.RouteValues["action"]);
Assert.AreEqual("P", actionResult.RouteValues["controller"]);
}