Exemplo n.º 1
0
        public void Create()
        {
            // Arrange
            ExemplaresController controller = new ExemplaresController();

            // Act
            ViewResult result = controller.Create() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Create", result.ViewName);
        }
Exemplo n.º 2
0
        public void SalvarDevePassar()
        {
            // Arrange
            ExemplaresController controller = new ExemplaresController();
            Exception            exception  = new Exception();
            Exemplar             exemplar   = this.InicializaExemplar();

            // Act
            ViewResult result = controller.Create(exemplar) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            ModelState modelState = result.ViewData.ModelState[""];

            Assert.IsNotNull(modelState);
            Assert.IsTrue(modelState.Errors.Any());
        }
Exemplo n.º 3
0
        public void SalvarDeveFalharValidacao2()
        {
            // Arrange
            ExemplaresController controller = new ExemplaresController();
            Exception            exception  = new Exception();
            Exemplar             exemplar   = this.InicializaExemplar();

            exemplar.titulo = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur volutpat ipsum eu ultrices congue. " +
                              "Pellentesque congue sem vel odio posuere, in cursus neque molestie. Pellentesque facilisis sapien faucibus augue gravida porta.";

            // Act
            ViewResult result = controller.Create(exemplar) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            ModelState modelState = result.ViewData.ModelState[""];

            Assert.IsNotNull(modelState);
            Assert.IsTrue(modelState.Errors.Any());
        }