public void EndreAvgang()
        {
            var controller = new LoginnController(new AvgangLogikk(new AvgangRepositoryStub()));


            var actionResult = (ViewResult)controller.EndreAvgang(1);


            Assert.AreEqual(actionResult.ViewName, "");
        }
        public void EndreAvgang_Ikke_Funnet_Ved_View()
        {
            var controller = new LoginnController(new AvgangLogikk(new AvgangRepositoryStub()));


            var actionResult   = (ViewResult)controller.EndreAvgang(0);
            var avgangResultat = (Avgang)actionResult.Model;


            Assert.AreEqual(actionResult.ViewName, "");
            Assert.AreEqual(avgangResultat.AId, 0);
        }
        public void EndreAvgang_feil_validering_Post()
        {
            var controller = new LoginnController(new AvgangLogikk(new AvgangRepositoryStub()));
            var innavgang  = new Avgang();

            controller.ViewData.ModelState.AddModelError("feil", "ID = 0");


            var actionResult = (ViewResult)controller.EndreAvgang(0, innavgang);


            Assert.IsTrue(actionResult.ViewData.ModelState.Count == 1);
            Assert.AreEqual(actionResult.ViewData.ModelState["feil"].Errors[0].ErrorMessage, "ID = 0");
            Assert.AreEqual(actionResult.ViewName, "");
        }
        public void EndreAvgang_funnet()
        {
            var controller = new LoginnController(new AvgangLogikk(new AvgangRepositoryStub()));
            var innavgang  = new Avgang()
            {
                FraogTiltid = "10:30-17:30",
                Lengdne     = "7timer",
                Price       = 599,
                StrekningId = 1
            };

            var actionResultat = (RedirectToRouteResult)controller.EndreAvgang(1, innavgang);


            Assert.AreEqual(actionResultat.RouteName, "");
            Assert.AreEqual(actionResultat.RouteValues.Values.First(), "HentAlleAvgang");
        }
        public void EndreAvgang_ikke_funnet_Post()
        {
            var controller = new LoginnController(new AvgangLogikk(new AvgangRepositoryStub()));
            var innavgang  = new Avgang()
            {
                AId         = 0,
                FraogTiltid = "10:30-17:30",
                Lengdne     = "7timer",
                Price       = 599,
                StrekningId = 1
            };


            var actionResult = (ViewResult)controller.EndreAvgang(0, innavgang);


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