public void Registrer()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlymaskinController(new FlymaskinBLL(new FlymaskinStub()));

            SessionMock.InitializeController(controller);
            controller.Session["LoggetInn"] = true;

            // Act
            var actionResult = (ViewResult)controller.RegistrerFlymaskin();

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
        }
        public void Registrer_session_ikke_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlymaskinController(new FlymaskinBLL(new FlymaskinStub()));

            SessionMock.InitializeController(controller);
            controller.Session["LoggetInn"] = false;

            // Act
            var result = (RedirectToRouteResult)controller.RegistrerFlymaskin();

            // Assert
            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "IngenTilgang");
        }
        public void Registrer_Post_DB_feil()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlymaskinController(new FlymaskinBLL(new FlymaskinStub()));

            SessionMock.InitializeController(controller);
            controller.Session["LoggetInn"] = true;

            var innFlymaskin = new Flymaskin();

            innFlymaskin.FlyId = "";

            // Act
            var actionResult = (ViewResult)controller.RegistrerFlymaskin(innFlymaskin);

            // Assert
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }
        public void Registrer_Post_Model_feil()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlymaskinController(new FlymaskinBLL(new FlymaskinStub()));

            SessionMock.InitializeController(controller);
            controller.Session["LoggetInn"] = true;

            var innFlymaskin = new Flymaskin();

            controller.ViewData.ModelState.AddModelError("flyId", "Ikke oppgitt flyId");

            // Act
            var actionResult = (ViewResult)controller.RegistrerFlymaskin(innFlymaskin);

            // Assert
            Assert.IsTrue(actionResult.ViewData.ModelState.Count == 1);
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }
        public void Registrer_Post_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlymaskinController(new FlymaskinBLL(new FlymaskinStub()));

            SessionMock.InitializeController(controller);
            controller.Session["LoggetInn"] = true;

            var innFlymaskin = new Flymaskin()
            {
                FlyId     = "AA00",
                Type      = "Boeing",
                Kapasitet = 100
            };
            // Act
            var result = (RedirectToRouteResult)controller.RegistrerFlymaskin(innFlymaskin);

            // Assert
            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "ListFlymaskiner");
        }
        public void Session_false()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlymaskinController(new FlymaskinBLL(new FlymaskinStub()));

            SessionMock.InitializeController(controller);

            controller.Session["LoggetInn"] = false;

            var innflymaskin = new Flymaskin()
            {
                FlyId     = "OSL",
                Kapasitet = 100,
                Type      = "Boeing 737"
            };

            // Act
            var result = (RedirectToRouteResult)controller.RegistrerFlymaskin(innflymaskin);

            // Assert
            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "IngenTilgang");
        }