Exemple #1
0
        public void GetPublicationsWithFavorites_GetPublicationsByAuthorId_Publications()
        {
            // Arrange
            _allPublications.AddRange(_publicationsWithAuthor);
            foreach (var publication in _publicationsWithAuthor)
            {
                _author.Favorites.Add(publication);
            }

            var getablePublication = new Mock <IGetablePublication>();
            var getableUser        = new Mock <IGetableUser>();

            var getFavorite = new GetFavorite(
                getablePublication.Object,
                getableUser.Object);

            getableUser.Setup(u => u.GetById(_author.Id))
            .Returns(_author);

            getablePublication.Setup(p => p.GetAllByAuthorId(_author.Id))
            .Returns(_publicationsWithAuthor);

            // Act
            var result = getFavorite.GetPublicationsWithFavorites(_author.Id);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(_publicationsWithAuthor, result);
            Assert.NotEqual(_allPublications, result);
            Assert.NotEqual(4, result.Count());
        }
Exemple #2
0
        public void GetPublicationsWithFavorites_GetPublicationsByAuthorIdIfAuthorDontHaveFavorites_FavoritesNotFoundException()
        {
            // Arrange
            var getablePublication = new Mock <IGetablePublication>();
            var getableUser        = new Mock <IGetableUser>();

            var getFavorite = new GetFavorite(
                getablePublication.Object,
                getableUser.Object);

            getableUser.Setup(u => u.GetById(_author.Id))
            .Returns(_author);

            // Act
            Action act = () => getFavorite.GetPublicationsWithFavorites(_author.Id);

            // Assert
            Assert.Throws <FavoritesNotFoundException>(act);
        }