Пример #1
0
        public async Task RefreshLatestVersionOfNewlyAddedPackagesAsync()
        {
            IReadOnlyCollection <Package> newPackages = await packageService.GetNewlyAddedPackagesAsync();

            PackageVersion[] versions = await GetLatestVersionsOfPackagesAsync(newPackages);

            await packageVersionService.UpdateLatestVersionsAsync(versions.Where(packageVersion => packageVersion != null));
        }
Пример #2
0
        public void UpdateLatestVersionOfNewPackagesAsync_Should_Invoke_Add_And_Update_When_Valid_Values()
        {
            List <PackageVersion> latestVersions = GetLatestPackageVersions();
            List <PackageVersion> versions       = GetPackageVersions();

            packageVersionsRepositoryMock
            .Setup(versionRepository => versionRepository.GetLatestVersionsAsync(It.IsAny <Expression <Func <PackageVersion, bool> > >()))
            .ReturnsAsync(latestVersions);

            packageVersionService.UpdateLatestVersionsAsync(versions);

            latestVersions.ForEach(packageVersion =>
                                   packageRepositoryMock.Verify(packageRepository => packageRepository.Update(packageVersion.Package)));

            packageVersionsRepositoryMock.Verify(versionRepository =>
                                                 versionRepository.Add(It.Is <PackageVersion>(packageVersion => packageVersion == versions.FirstOrDefault(version => version.Id == 2))));

            packageVersionsRepositoryMock.Verify(versionRepository =>
                                                 versionRepository.Update(It.Is <PackageVersion>(packageVersion => packageVersion == latestVersions.FirstOrDefault(latestVersion => latestVersion.Id == 1))));

            uowMock.Verify(uow => uow.SaveChangesAsync());
        }