Пример #1
0
        public void Registrer_feil_modell()
        {
            var controller    = new VareController(new VareBLL(new VareDALStub()));
            var ForventetVare = new Vare();

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

            // Act
            var actionResult = (ViewResult)controller.RegistrerVare(ForventetVare);

            // Assert
            Assert.IsTrue(actionResult.ViewData.ModelState.Count == 1);
            Assert.AreEqual(actionResult.ViewName, "");
        }
Пример #2
0
        public void Registrer_feil_db()
        {
            var controller = new VareController(new VareBLL(new VareDALStub()));

            var forventetVare = new Vare();

            forventetVare.Varenavn = "";

            // Act
            var actionResult = (ViewResult)controller.RegistrerVare(forventetVare);

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