예제 #1
0
        public void Slett_ikke_funnet_Post()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new BestillingController(new BestillingBLL(new BestillingStub()));

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

            // Bestilling Objekter
            var reiseFra = new Flyplass()
            {
                FlyplassKode = "OSL", By = "Oslo"
            };
            var reiseTil = new Flyplass()
            {
                FlyplassKode = "KRS", By = "Kristiansand"
            };
            var flymaskin = new Flymaskin()
            {
                FlyId = "AA00", Type = "Boeing", Kapasitet = 100
            };
            var rute = new Rute()
            {
                RuteId = "OSLKRS000", ReiseFra = reiseFra, ReiseTil = reiseTil, Dato = "10.10.2017", Tid = "10:00", ReiseTid = "10min", Flymaskin = flymaskin, Pris = 999
            };
            var poststed = new Poststed()
            {
                Postnr = "1000", Sted = "Oslo"
            };
            var kunde = new Kunde()
            {
                Fornavn = "Per", Etternavn = "Olsen", Adresse = "Osloveien 82", Poststed = poststed, Telefon = "12345678", Epost = "*****@*****.**", Aktiv = true
            };

            ;
            var innBestilling = new Bestilling()
            {
                Id    = 1,
                Rute  = rute,
                Kunde = kunde
            };

            // Act
            var actionResult = (ViewResult)controller.SlettBestilling(0, innBestilling);

            // Assert
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }
예제 #2
0
        public async Task SlettBestillingIkkeInnlogget()
        {
            mockRep.Setup(s => s.SlettBestilling(It.IsAny <int>())).ReturnsAsync(false);
            var BestillingController = new BestillingController(mockRep.Object, mockLog.Object);

            mockSession[_loggetInn] = _ikkeLoggetInn;
            mockHttpContext.Setup(s => s.Session).Returns(mockSession);
            BestillingController.ControllerContext.HttpContext = mockHttpContext.Object;

            var resultat = await BestillingController.SlettBestilling(It.IsAny <int>()) as UnauthorizedObjectResult;

            //Assert
            Assert.Equal((int)HttpStatusCode.Unauthorized, resultat.StatusCode);
            Assert.Equal("Ikke innlogget", resultat.Value);
        }
예제 #3
0
        public async Task SlettBestillingInnloggetIkkeOK()
        {
            mockRep.Setup(s => s.SlettBestilling(It.IsAny <int>())).ReturnsAsync(false);
            var BestillingController = new BestillingController(mockRep.Object, mockLog.Object);

            mockSession[_loggetInn] = _loggetInn;
            mockHttpContext.Setup(s => s.Session).Returns(mockSession);
            BestillingController.ControllerContext.HttpContext = mockHttpContext.Object;

            var resultat = await BestillingController.SlettBestilling(It.IsAny <int>()) as BadRequestObjectResult;

            //Assert
            Assert.Equal((int)HttpStatusCode.BadRequest, resultat.StatusCode);
            Assert.Equal("Bestilling ble ikke slettet", resultat.Value);
        }
예제 #4
0
        public void SlettBestilling_session_ikke_OK()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new BestillingController(new BestillingBLL(new BestillingStub()));

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

            // Act
            var result = (RedirectToRouteResult)controller.SlettBestilling(0);

            // Assert
            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "IngenTilgang");
        }
예제 #5
0
        public void SlettBestilling()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new BestillingController(new BestillingBLL(new BestillingStub()));

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

            // Act
            var actionResult = (ViewResult)controller.SlettBestilling(0);
            var resultat     = (Bestilling)actionResult.Model;

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
        }