Ejemplo n.º 1
0
        public void LikingPostShouldAddNewLikeInTheRepo()
        {
            // Arrange
            string loggedUserId = "bbb";
            string ipAddress = "fakeIp";
            int postId = 1;
            var postAuthor = new AuthorViewModel { Id = "aaa" };
            var likes = new List<LikeViewModel>();

            var postViewMock = new Mock<IPostView>();
            postViewMock.Setup(v => v.Id).Returns(postId);
            postViewMock.Setup(v => v.Author).Returns(postAuthor);
            postViewMock.Setup(v => v.Likes).Returns(likes);
            postViewMock.SetupSet(v => v.Likes = It.IsAny<List<LikeViewModel>>())
                .Callback<List<LikeViewModel>>((list) => likes = list);

            var fakePostPresenter = new PostPresenter(postViewMock.Object, this.mocksContainer.DataMock.Object);

            // Act
            fakePostPresenter.LikePost(loggedUserId, ipAddress);

            // Assert
            Assert.AreEqual(3, this.mocksContainer.LikesRepoMock.Object.All().Count());
        }
Ejemplo n.º 2
0
        public void LikingPostByTheAuthorShouldThrowExeption()
        {
            // Arrange
            string loggedUserId = "aaa";
            string ipAddress = "";
            int postId = 1;
            var postAuthor = new AuthorViewModel { Id = loggedUserId };

            var postViewMock = new Mock<IPostView>();
            postViewMock.Setup(v => v.Id).Returns(postId);
            postViewMock.Setup(v => v.Author).Returns(postAuthor);

            var fakePostPresenter = new PostPresenter(postViewMock.Object, this.mocksContainer.DataMock.Object);

            // Act
            fakePostPresenter.LikePost(loggedUserId, ipAddress);
        }