public Search ( string searchTerm, IEnumerable |
||
searchTerm | string | |
targetFrameworks | IEnumerable |
|
allowPrereleaseVersions | bool | |
리턴 | IQueryable |
public void ServerPackageRepositorySearch() { // Arrange var mockProjectSystem = new Mock<MockProjectSystem>() { CallBase = true }; _packageStreams = new Dictionary<string, MemoryStream>(); AddPackage(mockProjectSystem, "test", "1.0"); AddPackage(mockProjectSystem, "test2", "1.0"); AddPackage(mockProjectSystem, "test3", "1.0-alpha"); AddPackage(mockProjectSystem, "test4", "2.0"); var serverRepository = new ServerPackageRepository(new DefaultPackagePathResolver(mockProjectSystem.Object), mockProjectSystem.Object); serverRepository.HashProvider = GetHashProvider(); // Act var valid = serverRepository.Search("test3", true); var invalid = serverRepository.Search("test3", false); // Assert Assert.Equal("test3", valid.First().Id); Assert.Equal(0, invalid.Count()); }
public void ServerPackageRepositoryEmptyRepo() { // Arrange var mockProjectSystem = new Mock<MockProjectSystem>() { CallBase = true }; _packageStreams = new Dictionary<string, MemoryStream>(); var serverRepository = new ServerPackageRepository(new DefaultPackagePathResolver(mockProjectSystem.Object), mockProjectSystem.Object); serverRepository.HashProvider = GetHashProvider(); var package = CreatePackage("test", "1.0"); // Act var findPackage = serverRepository.FindPackage("test", new SemanticVersion("1.0")); var findPackagesById = serverRepository.FindPackagesById("test"); var getMetadataPackage = serverRepository.GetMetadataPackage(package); var getPackages = serverRepository.GetPackages().ToList(); var getPackagesWithDerivedData = serverRepository.GetPackagesWithDerivedData().ToList(); var getUpdates = serverRepository.GetUpdates(Enumerable.Empty<IPackageName>(), true, true, Enumerable.Empty<FrameworkName>(), Enumerable.Empty<IVersionSpec>()); var search = serverRepository.Search("test", true).ToList(); var source = serverRepository.Source; // Assert Assert.Null(findPackage); Assert.Empty(findPackagesById); Assert.Null(getMetadataPackage); Assert.Empty(getPackages); Assert.Null(getMetadataPackage); Assert.Empty(getPackagesWithDerivedData); Assert.Empty(getUpdates); Assert.Empty(search); Assert.NotEmpty(source); }
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); } }