Example #1
0
        public void SlettPoststed_session_ikke_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new PoststedController(new PoststedBLL(new PoststedStub()));

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

            // Act
            var result = (RedirectToRouteResult)controller.SlettPoststed("");

            // Assert
            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "IngenTilgang");
        }
Example #2
0
        public void SlettPoststed()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new PoststedController(new PoststedBLL(new PoststedStub()));

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

            // Act
            var actionResult = (ViewResult)controller.SlettPoststed("");
            var resultat     = (Poststed)actionResult.Model;

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
        }
Example #3
0
        public void Slett_ikke_funnet_Post()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new PoststedController(new PoststedBLL(new PoststedStub()));

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

            var innPoststed = new Poststed()
            {
                Postnr = "1000",
                Sted   = "Oslo"
            };

            // Act
            var actionResult = (ViewResult)controller.SlettPoststed("", innPoststed);

            // Assert
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }
Example #4
0
        public void Slettet_funnet_Post_session_ikke_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new PoststedController(new PoststedBLL(new PoststedStub()));

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

            var innPoststed = new Poststed()
            {
                Postnr = "1000",
                Sted   = "Oslo"
            };

            // Act
            var actionResult = (RedirectToRouteResult)controller.SlettPoststed("1000", innPoststed);

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