Пример #1
0
        public void endreBillett_IKKE_OK()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub()));

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

            Model.BestillingBilletter billett = new Model.BestillingBilletter()
            {
                Avreise            = new DateTime(2017, 10, 15, 10, 20, 0),
                Fra                = "Oslo",
                Til                = "Bergen",
                BillettId          = 2,
                PassasjerEtternavn = "Donald",
                PassasjerFornavn   = "Duck"
            };

            //Act
            var result = (ViewResult)controller.endreBillett(1, billett);

            //Assert
            Assert.AreEqual("", result.ViewName);
            Assert.AreEqual(true, controller.ViewBag.Feil);
        }
Пример #2
0
        public void hentEnBillett_FEIL_BILL()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub()));

            SessionMock.InitializeController(controller);
            controller.Session["LoggetInn"] = true;
            Model.BestillingBilletter funnetBillett = new Model.BestillingBilletter()
            {
                BillettId          = 12,
                Fra                = "Oslo",
                Til                = "Bergen",
                PassasjerEtternavn = "Duck",
                PassasjerFornavn   = "Donald",
                Avreise            = new DateTime(2017, 10, 20, 14, 0, 0)
            };

            //Act
            var result     = (ViewResult)controller.endreBillett(8);
            var hentetBill = result.Model as Model.BestillingBilletter;

            //Assert
            Assert.AreEqual("", result.ViewName);
            Assert.AreEqual(funnetBillett.Avreise, hentetBill.Avreise);
            Assert.AreEqual(funnetBillett.BillettId, hentetBill.BillettId);
            Assert.AreEqual(funnetBillett.Fra, hentetBill.Fra);
            Assert.AreEqual(funnetBillett.PassasjerFornavn, hentetBill.PassasjerFornavn);
            Assert.AreEqual(funnetBillett.PassasjerEtternavn, hentetBill.PassasjerEtternavn);
            Assert.AreNotEqual(funnetBillett.Til, hentetBill.Til);
        }
Пример #3
0
        public void endreBillett_OK()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub()));

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

            Model.BestillingBilletter billett = new Model.BestillingBilletter()
            {
                Avreise            = new DateTime(2017, 10, 15, 10, 20, 0),
                Fra                = "Oslo",
                Til                = "Bergen",
                BillettId          = 2,
                PassasjerEtternavn = "Donald",
                PassasjerFornavn   = "Duck"
            };

            //Act
            var result = (RedirectToRouteResult)controller.endreBillett(2, billett);

            //Assert
            result.AssertActionRedirect().ToAction("endreBestilling");
        }
Пример #4
0
        public void endreBillett_IKKE_LOGGET_INN()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController();

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

            //Act
            var actionResult = (RedirectToRouteResult)controller.endreBillett(0);

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