public async Task Test_ProgetRepository_Copy_And_Delete_Packages() { var localRepoFeedConfig = new Settings.Feed { Name = "local.choco", }; localRepoFeedConfig.Settings.Add("Uri", LocalRepoFolder); var targetRepoFeedConfig = new Settings.Feed { Name = "nuget.test", }; targetRepoFeedConfig.Settings.Add("Uri", RepoUrl); targetRepoFeedConfig.Settings.Add("ApiKey", ApiKey); var sourceRepo = new DirectoryRepository(localRepoFeedConfig, LoggerFactory); var targetRepo = new ProgetRepository(targetRepoFeedConfig, LoggerFactory); var sourcePackages = await sourceRepo.ListAsync(NotepadPlusPlusPackageId, false, true).ToListAsync(); foreach (var package in sourcePackages) { var p = await sourceRepo.FetchAsync(package.Id, package.Version); Assert.NotNull(p.Content); await targetRepo.AddAsync(p); } var targetPackages = await targetRepo.ListAsync(NotepadPlusPlusPackageId, false, true).ToListAsync(); Assert.Equal(NotepadPlusPlusPackageCount, sourcePackages.Count); Assert.Equal(NotepadPlusPlusPackageCount, targetPackages.Count); foreach (var targetPackage in targetPackages) { var targetPackageWithContent = await targetRepo.FetchAsync(targetPackage.Id, targetPackage.Version); Assert.NotNull(targetPackageWithContent.Content); await targetRepo.DeleteAsync(targetPackage.Id, targetPackage.Version); } targetPackages = await targetRepo.ListAsync(NotepadPlusPlusPackageId, false, true).ToListAsync(); Assert.Empty(targetPackages); }
public async Task Test_ProgetRepository_Fetch_Package_Not_Found() { var sourceRepoFeedConfig = new Settings.Feed { Name = "nuget.test", }; sourceRepoFeedConfig.Settings.Add("Uri", RepoUrl); sourceRepoFeedConfig.Settings.Add("ApiKey", ApiKey); var sourceRepo = new ProgetRepository(sourceRepoFeedConfig, LoggerFactory); try { Assert.Null(await sourceRepo.FetchAsync("PackageJunkName", "1.0.0")); } catch (Exception) { // Expected } }