Exemple #1
0
        public void ShouldCallPublishedPackageRepositoryUpdate()
        {
            IQueryable <PublishedPackage> publishedPackages = new[] { new PublishedPackage(), new PublishedPackage() }.AsQueryable();

            SetupEmptyPackageDataAggregateCollection();
            MockedPublishedPackageRepository.SetupGet(ppr => ppr.Collection).Returns(publishedPackages);

            Updater.IncrementDownloadForPackage(Guid.NewGuid().ToString());

            MockedPublishedPackageRepository.Verify(ppr => ppr.Update(It.IsAny <IEnumerable <PublishedPackage> >()), Times.Once(),
                                                    "PublishedPackageRepository's Update method was not invoked.");
        }
Exemple #2
0
        public void ShouldNotUpdateDownloadCountForNonMatchingPublishedPackage()
        {
            const int expectedDownloadCount    = 83;
            var       publishedPackageToIgnore = new PublishedPackage {
                DownloadCount = expectedDownloadCount
            };
            IQueryable <PublishedPackage> publishedPackages = new[] { publishedPackageToIgnore }.AsQueryable();

            MockedPublishedPackageRepository.SetupGet(ppr => ppr.Collection).Returns(publishedPackages);
            SetupEmptyPackageDataAggregateCollection();

            Updater.IncrementDownloadForPackage(Guid.NewGuid().ToString());

            Assert.AreEqual(expectedDownloadCount, publishedPackageToIgnore.DownloadCount, "DownloadCount for PublishedPackage was not updated.");
        }
Exemple #3
0
        public void ShouldUpdateDownloadCountOfMatchingPublishedPackage()
        {
            PublishedPackage publishedPackageToUpdate = new PublishedPackage {
                Id = Guid.NewGuid().ToString(), DownloadCount = 38
            };
            IQueryable <PublishedPackage> publishedPackages = new[] { publishedPackageToUpdate, new PublishedPackage() }.AsQueryable();
            var aggregate = new PackageDataAggregate {
                PackageId = publishedPackageToUpdate.Id, DownloadCount = 5
            };
            int expectedDownloadCount = aggregate.DownloadCount + 1;

            MockedPackageDataAggregateRepository.SetupGet(pdar => pdar.Collection).Returns(new[] { aggregate }.AsQueryable());
            MockedPublishedPackageRepository.SetupGet(ppr => ppr.Collection).Returns(publishedPackages);

            Updater.IncrementDownloadForPackage(publishedPackageToUpdate.Id);

            Assert.AreEqual(expectedDownloadCount, publishedPackageToUpdate.DownloadCount, "DownloadCount for PublishedPackage was not updated.");
        }