Ejemplo n.º 1
0
        public void Endre()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlyplassController(new FlyplassBLL(new FlyplassStub()));

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

            // Act
            var actionResult = (ViewResult)controller.EndreFlyplass("");

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
        }
Ejemplo n.º 2
0
        public void Endre_session_ikke_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlyplassController(new FlyplassBLL(new FlyplassStub()));

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

            // Act
            var actionResult = (RedirectToRouteResult)controller.EndreFlyplass("");

            // Assert
            Assert.AreEqual(actionResult.RouteName, "");
            Assert.AreEqual(actionResult.RouteValues.Values.First(), "IngenTilgang");
        }
Ejemplo n.º 3
0
        public void Endre_Ikke_Funnet_Ved_View()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlyplassController(new FlyplassBLL(new FlyplassStub()));

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

            // Act
            var actionResult     = (ViewResult)controller.EndreFlyplass("");
            var flyplassResultat = (Flyplass)actionResult.Model;

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
            Assert.AreEqual(flyplassResultat.FlyplassKode, "TST");
        }
Ejemplo n.º 4
0
        public void Endre_funnet()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlyplassController(new FlyplassBLL(new FlyplassStub()));

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

            var innFlyplass = new Flyplass()
            {
                FlyplassKode = "OSL",
                By           = "Oslo"
            };
            // Act
            var actionResultat = (RedirectToRouteResult)controller.EndreFlyplass("OSL", innFlyplass);

            // Assert
            Assert.AreEqual(actionResultat.RouteName, "");
            Assert.AreEqual(actionResultat.RouteValues.Values.First(), "ListFlyplasser");
        }
Ejemplo n.º 5
0
        public void Endre_feil_validering_Post()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlyplassController(new FlyplassBLL(new FlyplassStub()));

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

            var innFlyplass = new Flyplass();

            controller.ViewData.ModelState.AddModelError("feil", "FlyplassKode = ''");

            // Act
            var actionResult = (ViewResult)controller.EndreFlyplass("", innFlyplass);

            // Assert
            Assert.IsTrue(actionResult.ViewData.ModelState.Count == 1);
            Assert.AreEqual(actionResult.ViewData.ModelState["feil"].Errors[0].ErrorMessage, "FlyplassKode = ''");
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }
Ejemplo n.º 6
0
        public void Endre_ikke_funnet_Post()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlyplassController(new FlyplassBLL(new FlyplassStub()));

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

            var innFlyplass = new Flyplass()
            {
                FlyplassKode = "OSL",
                By           = "Oslo"
            };

            // Act
            var actionResult = (ViewResult)controller.EndreFlyplass("", innFlyplass);

            // Assert
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }