public async Task TestListDelistedPrereleaseAllVersions() { // Arrange var serviceAddress = TestUtility.CreateServiceAddress() + "api/v2"; var responses = new Dictionary <string, string>(); responses.Add( serviceAddress + "/Search()?$orderby=Id&searchTerm='Windows.AzureStorage'&targetFramework=''" + "&includePrerelease=true&$skip=0&$top=30&semVerLevel=2.0.0", TestUtility.GetResource("NuGet.Protocol.Tests.compiler.resources.WindowsAzureStorageSearchPackage30Entries.xml", GetType())); responses.Add( serviceAddress + "/Search()?$orderby=Id&searchTerm='Windows.AzureStorage'&targetFramework=''" + "&includePrerelease=true&$skip=30&$top=30&semVerLevel=2.0.0", TestUtility.GetResource("NuGet.Protocol.Tests.compiler.resources.WindowsAzureStorageSearchPackage17Entries.xml", GetType())); responses.Add(serviceAddress, string.Empty); responses.Add(serviceAddress + "/$metadata", TestUtility.GetResource("NuGet.Protocol.Tests.compiler.resources.MetadataTT.xml", GetType())); var httpSource = new TestHttpSource(new PackageSource(serviceAddress), responses); var parser = new V2FeedParser(httpSource, serviceAddress); var legacyResource = new LegacyFeedCapabilityResourceV2Feed(parser, serviceAddress); var resource = new V2FeedListResource(parser, legacyResource, serviceAddress); var enumerable = await resource.ListAsync(searchTerm : "Windows.AzureStorage", prerelease : true, allVersions : true, includeDelisted : true, logger : NullLogger.Instance, token : CancellationToken.None); //Only 2 packages are listed in this resource int ExpectedCount = 47; int ActualCount = 0; var enumerator = enumerable.GetEnumeratorAsync(); while (await enumerator.MoveNextAsync()) { if (enumerator.Current != null) { ActualCount++; Assert.True(ExpectedCount >= ActualCount, "Too many results"); } else { Assert.False(false, "Null Value, this shouldn't happen."); } } Assert.Equal(ExpectedCount, ActualCount); }
public async Task TestUsesReferenceCache() { // Arrange var serviceAddress = TestUtility.CreateServiceAddress() + "api/v2"; var responses = new Dictionary <string, string>(); responses.Add( serviceAddress + "/Search()?$orderby=Id&searchTerm='afine'" + "&targetFramework=''&includePrerelease=false&$skip=0&$top=30&semVerLevel=2.0.0", TestUtility.GetResource("NuGet.Protocol.Tests.compiler.resources.SearchV2WithDuplicateBesidesVersion.xml", GetType())); responses.Add(serviceAddress, string.Empty); responses.Add(serviceAddress + "/$metadata", TestUtility.GetResource("NuGet.Protocol.Tests.compiler.resources.MetadataTT.xml", GetType())); var httpSource = new TestHttpSource(new PackageSource(serviceAddress), responses); var parser = new V2FeedParser(httpSource, serviceAddress); var legacyResource = new LegacyFeedCapabilityResourceV2Feed(parser, serviceAddress); var resource = new V2FeedListResource(parser, legacyResource, serviceAddress); var enumerable = await resource.ListAsync(searchTerm : "afine", prerelease : false, allVersions : true, includeDelisted : true, logger : NullLogger.Instance, token : CancellationToken.None); int ExpectedCount = 2; int ActualCount = 0; var enumerator = enumerable.GetEnumeratorAsync(); var packages = new List <PackageSearchMetadataBuilder.ClonedPackageSearchMetadata>(); while (await enumerator.MoveNextAsync()) { if (enumerator.Current != null) { ActualCount++; Assert.True(ExpectedCount >= ActualCount, "Too many results"); packages.Add((PackageSearchMetadataBuilder.ClonedPackageSearchMetadata)enumerator.Current); } else { Assert.False(false, "Null Value, this shouldn't happen."); } } Assert.Equal(ExpectedCount, ActualCount); MetadataReferenceCacheTestUtility.AssertPackagesHaveSameReferences(packages[0], packages[1]); }
public async Task LegacyResourceNoSearchNoAbsoluteLatestVersion() { // Arrange var serviceAddress = ProtocolUtility.CreateServiceAddress() + "api/v2"; var responses = new Dictionary <string, string>(); responses.Add(serviceAddress + "/$metadata", ProtocolUtility.GetResource("NuGet.Protocol.Tests.compiler.resources.MetadataFF.xml", GetType())); responses.Add(serviceAddress, string.Empty); var httpSource = new TestHttpSource(new PackageSource(serviceAddress), responses); V2FeedParser parser = new V2FeedParser(httpSource, serviceAddress); LegacyFeedCapabilityResourceV2Feed legacyResource = new LegacyFeedCapabilityResourceV2Feed(parser, serviceAddress); Assert.False(await legacyResource.SupportsSearchAsync(NullLogger.Instance, CancellationToken.None)); Assert.False(await legacyResource.SupportsIsAbsoluteLatestVersionAsync(NullLogger.Instance, CancellationToken.None)); }