【发布时间】:2014-03-26 14:17:19
【问题描述】:
[TestMethod]
public void UnitTestMethod1()
{
Test1Controller controller = new Test1Controller();
//This call throws NullReferenceException "Object reference not set to an instance of an object."
WebSecurity.Login("User1", "password1");
controller.TestMethod();
}
在上面的代码中如何使 WebSecurity.Login 调用起作用?
我做了研究,但没有帮助much
谢谢。
【问题讨论】:
-
谢谢你,尼尔。 WebSecurity.Login 使用 FormsAuthentication.SetAuthCookie 实际抛出异常。
标签: c# asp.net-mvc unit-testing