Esempio n. 1
0
        public void AdministrerReiser_IKKE_LOGGET_INN()
        {
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController();

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

            //Act
            var actionResult = (RedirectToRouteResult)controller.AdministrerReiser("", "", "", 0);

            //Assert
            Assert.AreEqual("Login", actionResult.RouteValues.Values.First());
        }
Esempio n. 2
0
        public void hentAlleReise()
        {
            //Arrange
            //Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new ClearSkiesController(new AirlineLogikk(new AirlineDALStub()));

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

            var nyReise = new Model.ReiseView()
            {
                ReiseId     = 1,
                Fra         = "Gatwick, UK",
                Destinasjon = "Gardermoen, Norge",
                Avreise     = new DateTime(2017, 10, 18, 16, 10, 0, 0),
                Ankomst     = new DateTime(2017, 10, 18, 17, 40, 0, 0),
                Varighet    = "1 time og 30 minutter",
                Kapasitet   = 20,
                Pris        = 299
            };

            //Act
            var result     = (ViewResult)controller.AdministrerReiser("", "", "", 0);
            var listResult = (PagedList.IPagedList <Model.ReiseView>)result.Model;
            List <Model.ReiseView> konvertert = new List <Model.ReiseView>();

            //Assert
            Assert.AreEqual("", result.ViewName);

            foreach (var r in listResult)
            {
                Assert.AreEqual(r.Destinasjon, nyReise.Destinasjon);
                Assert.AreEqual(r.Avreise, nyReise.Avreise);
                Assert.AreEqual(r.Ankomst, nyReise.Ankomst);
                Assert.AreEqual(r.Fra, nyReise.Fra);
                Assert.AreEqual(r.Kapasitet, nyReise.Kapasitet);
                Assert.AreEqual(r.Pris, nyReise.Pris);
                Assert.AreEqual(r.ReiseId, nyReise.ReiseId);
                Assert.AreEqual(r.Varighet, nyReise.Varighet);
            }
        }