Пример #1
0
        public async Task CommentTest_Post_AddsCommentsToRepository_AndRedirectsToIndex()
        {
            // Arrange
            var postId          = 1;
            var res             = false;
            var objectsComments = new Comments {
                CommentMsg = "mock article 1", CommentedDate = DateTime.Now, PostID = 1
            };
            //blogPostRepoMock.Setup(repo => repo.Create(objectsBlogPost)).Returns(Task.CompletedTask);

            // Act
            var result = await blogController.Comments(postId, objectsComments);

            // Assert
            blogPostServMock.Verify(repo => repo.Comments(postId, objectsComments));
            var viewResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Index", viewResult.ActionName);
            if (viewResult.ActionName == "Index")
            {
                res = true;
            }
            File.AppendAllText("../../../../output_revised.txt",
                               "CommentTest_Post_AddsCommentsToRepository_AndRedirectsToIndex="
                               + res.ToString() + "\n");
        }