public void main_login_view()
        {
            // Arrange 
            var controller = new MainController();
            // Act
            var result = (ViewResult)controller.LogIn();

            //Assert
            Assert.AreEqual(result.ViewName, "");
        }
        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"]);

        }
 public void logged_inn_Main()
 {
     //Arrange
     TestControllerBuilder builder = new TestControllerBuilder();
     //arrange
     var bll = new MainController();
     builder.InitializeController(bll);
     builder.HttpContext.Session["loggedInUser"] = new Customer() { admin = true };
  
     //Act
     var result = (ViewResult)bll.Main();
     //Assert
     Assert.AreEqual(result.ViewName, "");
 }
        public void main_logout()
        {
            TestControllerBuilder builder = new TestControllerBuilder();
            //Arrange
            var controller = new MainController();
            builder.InitializeController(controller);
            //Act
          var result = (RedirectToRouteResult)controller.logOut();
            //Assert
            Assert.AreEqual("LogIn", result.RouteValues["Action"]);



          




        }