내가 이런 루틴 뭔가를 :단위 테스트 및 세션?
public bool IsValidEmployee(string email, string password)
{
bool valid = false;
var employee = dataAccess.GetEmployee(email, password);
if(employee! = null)
{
valid = true;
HttpContext.Current.Session["Employee"] = employee;
}
return valid;
}
내 단위 테스트 :
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\Projects", "/")]
[UrlToTest("http://localhost:59349/")]
public void GetEmployeeTest()
{
Domain target = new Domain();
var mockHttpContext = new Mock<HttpContextBase>();
mockHttpContext.SetupSet(c => c.Session["Employee"] = It.IsAny<object>());
Assert.IsTrue(target.IsValidEmployee("[email protected]", "test");
}
코드가 실패 에
객체 Null 참조 '로 HttpContext.Current.Session [ "Employee"] = employee; '
이 오류를 해결할 수있는 방법은 무엇입니까?