Пример #1
0
        public void AddTest_ReturnsBadRequest_WhenModelStateIsInvalid()
        {
            //arrange
            var titleMissing = new Post()
            {
                Id = new Guid("815accac-fd5b-478a-a9d6-f171a2f6ae7f"), Content = "Learning is fun"
            };

            _blogController.ModelState.AddModelError("Title", "Title field is required");

            //act
            var result = _blogController.Add(titleMissing);

            //assert
            Assert.IsAssignableFrom <BadRequestObjectResult>(result);
        }
Пример #2
0
        public void AddTest_ReturnsBadRequest_WhenModelStateIsInvalid()
        {
            //arrange:
            var post = new Post()
            {
                Id = new Guid("815accac-fd5b-478a-a9d6-f171a2f6ae7f"), Content = "Learning is fun"
            };

            _blogController.ModelState.AddModelError("Title", "Titulo é Obrigatorio");

            //act:
            var result = _blogController.Add(post);

            //assert:
            Assert.IsAssignableFrom <BadRequestObjectResult>(result);
        }