Ejemplo n.º 1
0
        public void Delete_WhenCalledWithNonExistingId_ReturnsNotFound()
        {
            // var mockService = new Mock<IBlogPostService>();
            var fakePost = new BlogPost {
                Id = 1, Title = "First BlogPost", Author = "Oscar Recio", Content = "First BlogPost by Oscar Recio"
            };

            mockService.Setup(serv => serv.GetById(1)).Returns(fakePost);

            //Given
            BlogPostController blogPostController = new BlogPostController(mockService.Object);

            //When
            var getResult = blogPostController.Delete(4);

            //Then
            Assert.IsType <NotFoundResult>(getResult);
        }
Ejemplo n.º 2
0
        public void Delete_WhenCalledWithExistingId_ReturnsStatusCode()
        {
            //    var mockService = new Mock<IBlogPostService>();
            var fakePost = new BlogPost {
                Id = 1, Title = "First BlogPost", Author = "Oscar Recio", Content = "First BlogPost by Oscar Recio"
            };

            mockService.Setup(serv => serv.GetById(1)).Returns(fakePost);

            //Given
            BlogPostController blogPostController = new BlogPostController(mockService.Object);

            //When
            var getResult = blogPostController.Delete(1);

            //Then
            var result = Assert.IsType <StatusCodeResult>(getResult);

            Assert.Equal(410, result.StatusCode);
        }