Example #1
0
        public void Comment_ShouldCallPostServiceGetById()
        {
            // Arrange
            var categoryServiceMock = new Mock <ICategoryService>();
            var postServiceMock     = new Mock <IPostService>();
            var voteServiceMock     = new Mock <IVoteService>();
            var commentServiceMock  = new Mock <ICommentService>();
            var userManagerMock     = new Mock <IApplicationUserManager>();
            var mapperMock          = new Mock <IMapper>();

            var controller = new PostsController(
                categoryServiceMock.Object,
                postServiceMock.Object,
                voteServiceMock.Object,
                commentServiceMock.Object,
                userManagerMock.Object,
                mapperMock.Object);
            var model = new CommentAddViewModel();

            // Act
            var result = controller.Comment(model);

            // Assert
            postServiceMock.Verify(x => x.GetById(It.IsAny <Guid>(), It.IsAny <bool>()), Times.Once);
        }