In controller I have a method that name Login. In that method we use session. So how to write unit testing?
[HttpPost]
public ActionResult Login(LoginModel lVM)
{
LoginViewModel model = UM.Authentication(lVM);
if (model.UserId > 0)
{
Session["LoginMessage"] = model.UserName;
Session["UserID"] = model.UserId;
IDataHelper ex = new DataHelper();
return RedirectToAction("HomePage", "Newcontroller");
}
else
{
Session["LoginMessage"] = "Invalid UserName and Password";
return RedirectToAction("Login", "Login");
}
}
Aucun commentaire:
Enregistrer un commentaire