public void Endre_funnet_session_ikke_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new KundeController(new KundeBLL(new KundeStub()));

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

            var innKunde = new Kunde()
            {
                Fornavn   = "Per",
                Etternavn = "Olsen",
                Adresse   = "Osloveien 82",
                Poststed  = poststed,
                Telefon   = "12345678",
                Epost     = "*****@*****.**",
                Aktiv     = true
            };
            // Act
            var result = (RedirectToRouteResult)controller.EndreKunde("*****@*****.**", innKunde);

            // Assert
            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "IngenTilgang");
        }
        public void Endre_ikke_funnet_Post()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new KundeController(new KundeBLL(new KundeStub()));

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

            var innKunde = new Kunde()
            {
                Fornavn   = "Per",
                Etternavn = "Olsen",
                Adresse   = "Osloveien 82",
                Poststed  = poststed,
                Telefon   = "12345678",
                Epost     = "*****@*****.**",
                Aktiv     = true
            };

            // Act
            var actionResult = (ViewResult)controller.EndreKunde("", innKunde);

            // Assert
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }
        public void Endre()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new KundeController(new KundeBLL(new KundeStub()));

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

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

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
        }
        public void Endre_session_ikke_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new KundeController(new KundeBLL(new KundeStub()));

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

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

            // Assert
            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "IngenTilgang");
        }
        public void Endre_Ikke_Funnet_Ved_View()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new KundeController(new KundeBLL(new KundeStub()));

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

            // Act
            var actionResult     = (ViewResult)controller.EndreKunde("");
            var flyplassResultat = (Kunde)actionResult.Model;

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
            Assert.AreEqual(flyplassResultat.Epost, "*****@*****.**");
        }
        public void Endre_feil_validering_Post()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new KundeController(new KundeBLL(new KundeStub()));

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

            var innKunde = new Kunde();

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

            // Act
            var actionResult = (ViewResult)controller.EndreKunde("", innKunde);

            // Assert
            Assert.IsTrue(actionResult.ViewData.ModelState.Count == 1);
            Assert.AreEqual(actionResult.ViewData.ModelState["feil"].Errors[0].ErrorMessage, "Epost = ''");
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }