示例#1
0
        public void Registrer_Post_Model_feil()
        {
            // Arrange
            var SessionMock = new TestControllerBuilder();
            var controller  = new FlyplassController(new FlyplassBLL(new FlyplassStub()));

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

            var innFlyplass = new Flyplass();

            controller.ViewData.ModelState.AddModelError("flyplassKode", "Ikke oppgitt flyplassKode");

            // Act
            var actionResult = (ViewResult)controller.RegistrerFlyplass(innFlyplass);

            // Assert
            Assert.IsTrue(actionResult.ViewData.ModelState.Count == 1);
            Assert.AreEqual(actionResult.ViewName, "~/Views/Error/Error.cshtml");
        }