public RemovePackage ( IPackage package ) : void | ||
package | IPackage | |
Résultat | void |
public void ServerPackageRepositoryRemovePackage() { // Arrange var mockProjectSystem = new Mock<MockProjectSystem>() { CallBase = true }; _packageStreams = new Dictionary<string, MemoryStream>(); AddPackage(mockProjectSystem, "test", "1.11"); AddPackage(mockProjectSystem, "test", "1.9"); AddPackage(mockProjectSystem, "test", "2.0-alpha"); var serverRepository = new ServerPackageRepository(new DefaultPackagePathResolver(mockProjectSystem.Object), mockProjectSystem.Object); serverRepository.HashProvider = GetHashProvider(); var package = CreatePackage("test", "1.11"); var package2 = CreatePackage("test", "2.0-alpha"); // call to cache the first time var packages = serverRepository.GetPackagesWithDerivedData(); // Act serverRepository.RemovePackage(package); serverRepository.RemovePackage(package2); packages = serverRepository.GetPackagesWithDerivedData(); // Assert Assert.Equal(1, packages.Count()); Assert.Equal(1, packages.Where(p => p.IsLatestVersion).Count()); Assert.Equal("1.9", packages.Where(p => p.IsLatestVersion).First().Version); Assert.Equal(1, packages.Where(p => p.IsAbsoluteLatestVersion).Count()); Assert.Equal("1.9", packages.Where(p => p.IsAbsoluteLatestVersion).First().Version); }
public void ServerPackageRepositorySearchUnlisted() { var tempPath = Path.GetTempPath(); var workingDirectory = Path.Combine(tempPath, Guid.NewGuid().ToString()); try { // Arrange // create the server repo, from a directory containing a package. Func<string, bool, bool> settingsFunc = (key, defaultValue) => { if (key == "enableDelisting") { return true; } return defaultValue; }; CreateDirectory(workingDirectory); var packageFile = CreatePackage("test1", "1.0", workingDirectory); var fileSystem = new PhysicalFileSystem(workingDirectory); var serverRepository = new ServerPackageRepository( new DefaultPackagePathResolver(fileSystem), fileSystem, settingsFunc) { HashProvider = GetHashProvider().Object }; var packages = serverRepository.Search("test1", true).ToList(); Assert.Equal(1, packages.Count); Assert.Equal("test1", packages[0].Id); Assert.Equal("1.0", packages[0].Version.ToString()); // delist the package serverRepository.RemovePackage("test1", new SemanticVersion("1.0")); // verify that the package is not returned by search packages = serverRepository.Search("test1", true).ToList(); Assert.Equal(0, packages.Count); // Act: search with includeDelisted=true packages = serverRepository.Search( "test1", targetFrameworks: Enumerable.Empty<string>(), allowPrereleaseVersions: true, includeDelisted: true).ToList(); // Verify Assert.Equal(1, packages.Count); Assert.Equal("test1", packages[0].Id); Assert.Equal("1.0", packages[0].Version.ToString()); } finally { // Cleanup DeleteDirectory(workingDirectory); } }