Exemplo n.º 1
0
        public void CallPublicationRepository_UpdateOnce()
        {
            // Arrange
            var mockedPublicationRepository = new Mock <IEFRepository <Publication> >();
            var publication = new Publication();

            mockedPublicationRepository.Setup(x => x.GetById(It.IsAny <int>())).Returns(publication);
            var mockedFriendsService          = new Mock <IFriendService>();
            var mockedUserService             = new Mock <IUserService>();
            var mockedUnitOfWork              = new Mock <IUnitOfWork>();
            var mockedPublicationFactory      = new Mock <IPublicationFactory>();
            var mockedDateTimeService         = new Mock <IDateTimeService>();
            var mockedPublicationImageFactory = new Mock <IPublicationImageFactory>();
            var mockedCommentService          = new Mock <ICommentService>();

            var publicationService = new PublicationService(
                mockedPublicationRepository.Object,
                mockedFriendsService.Object,
                mockedUserService.Object,
                mockedUnitOfWork.Object,
                mockedPublicationFactory.Object,
                mockedDateTimeService.Object,
                mockedPublicationImageFactory.Object,
                mockedCommentService.Object);
            int publicationId = 12;

            // Act
            publicationService.AddLike(publicationId);

            // Assert
            mockedPublicationRepository.Verify(x => x.Update(It.Is <Publication>(p => p == publication)), Times.Once);
        }
Exemplo n.º 2
0
        public void IncreasePublicationLikes_WithOne()
        {
            // Arrange
            var mockedPublicationRepository = new Mock <IEFRepository <Publication> >();
            var publication = new Publication();

            mockedPublicationRepository.Setup(x => x.GetById(It.IsAny <int>())).Returns(publication);
            var mockedFriendsService          = new Mock <IFriendService>();
            var mockedUserService             = new Mock <IUserService>();
            var mockedUnitOfWork              = new Mock <IUnitOfWork>();
            var mockedPublicationFactory      = new Mock <IPublicationFactory>();
            var mockedDateTimeService         = new Mock <IDateTimeService>();
            var mockedPublicationImageFactory = new Mock <IPublicationImageFactory>();
            var mockedCommentService          = new Mock <ICommentService>();

            var publicationService = new PublicationService(
                mockedPublicationRepository.Object,
                mockedFriendsService.Object,
                mockedUserService.Object,
                mockedUnitOfWork.Object,
                mockedPublicationFactory.Object,
                mockedDateTimeService.Object,
                mockedPublicationImageFactory.Object,
                mockedCommentService.Object);
            int publicationId = 12;

            // Act
            publicationService.AddLike(publicationId);

            // Assert
            Assert.AreEqual(publication.Likes, 1);
        }