Пример #1
0
        public void Test3_GetBySlug_ShouldFail()
        {
            // Arrange
            var controller = new BlogController(_context);

            // Act
            IActionResult    actionResult = controller.GetBySlug("this-slug-is-not-in-db");
            StatusCodeResult result       = Assert.IsType <StatusCodeResult>(actionResult);

            // Assert
            Assert.Equal(404, result.StatusCode);
        }
Пример #2
0
        public void Test2_GetBySlug_ShouldPass()
        {
            // Arrange
            var controller = new BlogController(_context);

            // Act
            IActionResult actionResult   = controller.GetBySlug("my-slug-1");
            var           okObjectResult = Assert.IsType <OkObjectResult>(actionResult);
            Post          post           = okObjectResult.Value as Post;

            // Assert
            Assert.Equal(1, post.ID);
            Assert.Equal("Text1", post.Text);
        }