public void main_login_modelstate_valid_ok_admin_is_null() { // Arrange var controller = new MainController(new CustomerBLL(new CustomerDALStub())); LogIn cust = new LogIn() { email = "", password = "" }; // Act var result = (ViewResult)controller.logIn(cust); // Assert Assert.AreEqual("", result.ViewName); Assert.IsTrue(result.ViewData.ModelState.Count == 0); }
public void main_login_modelstate_is_invalid() { // Arrange var controller = new MainController(new CustomerBLL(new CustomerDALStub())); controller.ViewData.ModelState.AddModelError("feil", "dette ble feil gitt"); LogIn cust = new LogIn() { email = "", password = "" }; // Act var result = (ViewResult)controller.logIn(cust); //Assert Assert.AreEqual("", result.ViewName); Assert.IsTrue(result.ViewData.ModelState.Count == 1); }
public void main_login_redirect_to_main_login_OK() { TestControllerBuilder builder = new TestControllerBuilder(); // Arrange var controller = new MainController(new CustomerBLL(new CustomerDALStub())); builder.InitializeController(controller); LogIn cust = new LogIn() { email = "*****@*****.**", password = "******" }; // Act var result = (RedirectToRouteResult)controller.logIn(cust); //Assert Assert.AreEqual("Main", result.RouteValues["Action"]); }