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

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

            DateTime dato  = new DateTime(2017, 10, 20);
            DateTime tid1  = new DateTime(2017, 10, 20, 12, 00, 0);
            DateTime tid2  = new DateTime(2017, 10, 20, 14, 00, 0);
            var      reise = new Model.ReiseReg()
            {
                Fra         = "Oslo",
                Destinasjon = "Bergen",
                Avreise     = dato,
                AvreiseTid  = tid1,
                Ankomst     = dato,
                AnkomstTid  = tid2,
                Kapasitet   = 150,
                Pris        = 299
            };

            //Act
            var actionResult = (RedirectToRouteResult)controller.RegistrerReise(reise);

            //Assert
            actionResult.AssertActionRedirect().ToAction("AdministrerReiser");
        }
Пример #2
0
        public void RegistrerReise_FEIL_DATO()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub()));

            SessionMock.InitializeController(controller);
            controller.Session["LoggetInn"] = true;
            DateTime dato1 = new DateTime(2017, 10, 20);
            DateTime dato2 = new DateTime(2017, 10, 19);
            DateTime tid1  = new DateTime(2017, 10, 20, 12, 00, 0);
            DateTime tid2  = new DateTime(2017, 10, 20, 14, 00, 0);
            var      reise = new Model.ReiseReg()
            {
                Fra         = "Oslo",
                Destinasjon = "Bergen",
                Avreise     = dato1,
                AvreiseTid  = tid1,
                Ankomst     = dato2,
                AnkomstTid  = tid2,
                Kapasitet   = 150,
                Pris        = 299
            };

            //Act
            var actionResult = (ViewResult)controller.RegistrerReise(reise);

            //Assert
            Assert.AreEqual(actionResult.ViewName, "");
            Assert.IsNotNull(actionResult.ViewBag.registrert);
            Assert.AreEqual("Feil", actionResult.ViewBag.registrert);
        }
Пример #3
0
        public void RegistrerReise_LOGGET_INN()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController();

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


            //Act
            var actionResult = (ViewResult)controller.RegistrerReise();

            //Assert
            Assert.AreEqual("", actionResult.ViewName);
        }
Пример #4
0
        public void RegistrerReise_IKKE_LOGGET_INN()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController();

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


            //Act
            var actionResult = (RedirectToRouteResult)controller.RegistrerReise();

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