Ejemplo n.º 1
0
        public void EndreAvgang()
        {
            var kontroller  = new DefaultController(new TogLogikk(new Togstub()));
            var SessionMock = new TestControllerBuilder();

            SessionMock.InitializeController(kontroller);
            kontroller.Session["loggetInn"] = true;
            var res = (ViewResult)kontroller.EndreAvgang(1);

            Assert.AreEqual(true, res.ViewData["Innlogget"]);
            Assert.AreEqual(res.ViewName, "");
        }
Ejemplo n.º 2
0
        public void EndreAvgangPostFeil()
        {
            var controller2 = new DefaultController(new TogLogikk(new Togstub()));
            var SessionMock = new TestControllerBuilder();

            SessionMock.InitializeController(controller2);
            controller2.Session["loggetInn"] = true;
            var avgang = new avgangs();

            avgang.AvgangId = 0;
            //Act
            var resultat2 = (ViewResult)controller2.EndreAvgang(avgang);

            //Assert
            Assert.AreEqual(resultat2.ViewName, "");
            Assert.AreEqual(true, resultat2.ViewData["Innlogget"]);
        }
Ejemplo n.º 3
0
        public void EndreAvgangPostOk()
        {
            var kontroller  = new DefaultController(new TogLogikk(new Togstub()));
            var SessionMock = new TestControllerBuilder();

            SessionMock.InitializeController(kontroller);

            kontroller.Session["feilStrekning"] = false;
            kontroller.Session["loggetInn"]     = true;
            TimeSpan s      = new TimeSpan(10, 1, 2);
            var      avgang = new avgangs()
            {
                AvgangId  = 2,
                Tid       = s,
                StasjonId = 3,
                TogId     = 1
            };

            var res = (RedirectToRouteResult)kontroller.EndreAvgang(avgang);

            Assert.AreEqual(res.RouteName, "");
            Assert.AreEqual(res.RouteValues.Values.First(), "Avganger");
        }