コード例 #1
0
        public void EditComment_ValidComment_Test()
        {
            var init = new InitializeMockContext();
            var mock = init.mock;

            var controller     = new PostCommentsService(mock.Object, mapper);
            var expectedString = "Testowy Komentarz";
            var editedCom      = controller.EditComment(new EditPostCommentCommand {
                Id = 1, Content = expectedString
            });

            mock.Verify(m => m.SaveChanges(), Times.Once());
            Assert.AreEqual(expectedString, editedCom.Content);
        }
コード例 #2
0
        public void EditComment_BoolEdited_ChangeToTrue()
        {
            var init = new InitializeMockContext();
            var mock = init.mock;

            var postCommentsService = new PostCommentsService(mock.Object, mapper);
            var expectedBool        = mock.Object.PostComments.First(x => x.Id == 1).Edited;
            var editedPost          = postCommentsService.EditComment(new EditPostCommentCommand {
                Id = 1
            });

            mock.Verify(m => m.SaveChanges(), Times.Once());
            Assert.AreEqual(expectedBool, null);
            Assert.AreEqual(true, editedPost.Edited);
        }