public async Task GetUpdates_IncludesSemVerV2PackageVersionsWhenSemVerLevel2OrHigher(string semVerLevel) { // Arrange const string currentVersionString = "1.0.0"; var currentVersion = NuGetVersion.Parse(currentVersionString); var expected = AvailablePackages.Where(p => NuGetVersion.Parse(p.Version) > currentVersion); // Act var resultSet = await GetCollection <V2FeedPackage>( (controller, options) => controller.GetUpdates(options, TestPackageId, currentVersionString, includePrerelease: true, includeAllVersions: true, semVerLevel: semVerLevel), $"/api/v2/GetUpdates()?packageIds='{TestPackageId}'&versions='{currentVersionString}'&includePrerelease=true&includeAllVersions=true&semVerLevel={semVerLevel}"); // Assert foreach (var package in SemVer2Packages.Where(p => NuGetVersion.Parse(p.Version) > currentVersion)) { // Assert all of the SemVer2 packages are included in the result. // Whilst at it, also check the NormalizedVersion on the OData feed. Assert.Single(resultSet.Where(feedPackage => string.Equals(feedPackage.Version, package.Version) && string.Equals(feedPackage.NormalizedVersion, package.NormalizedVersion) && string.Equals(feedPackage.Id, package.PackageRegistration.Id))); } foreach (var package in NonSemVer2Packages.Where(p => NuGetVersion.Parse(p.Version) > currentVersion)) { // Assert all of the non-SemVer2 packages are included in the result. // Whilst at it, also check the NormalizedVersion on the OData feed. Assert.Single(resultSet.Where(feedPackage => string.Equals(feedPackage.Version, package.Version) && string.Equals(feedPackage.NormalizedVersion, package.NormalizedVersion) && string.Equals(feedPackage.Id, package.PackageRegistration.Id))); } Assert.Equal(expected.Count(), resultSet.Count); }
private void AssertResultCorrect(IEnumerable <V2FeedPackage> resultSet) { foreach (var feedPackage in resultSet) { // Assert none of the items in the result set are SemVer v.2.0.0 packages (checking on original version is enough in this case) Assert.Empty(SemVer2Packages.Where(p => string.Equals(p.Version, feedPackage.Version))); // Assert each of the items in the result set is a non-SemVer v2.0.0 package Assert.Single(NonSemVer2Packages.Where(p => string.Equals(p.Version, feedPackage.Version) && string.Equals(p.PackageRegistration.Id, feedPackage.Id))); } }
public async Task SearchIsLatestVersion_ReturnsLatestStableSemVer2_WhenSemVerLevel200() { // Act var resultSet = await GetCollection <V2FeedPackage>( async (controller, options) => await controller.Search( options, searchTerm: TestPackageId, includePrerelease: true, semVerLevel: SemVerLevelKey.SemVerLevel2), $"/api/v2/Search?$filter=IsLatestVersion&searchTerm='{TestPackageId}'&includePrerelease=true&semVerLevel=2.0.0"); // Assert Assert.Equal(SemVer2Packages.Single(p => p.IsLatestStableSemVer2).Version, resultSet.Single().Version); }
private void AssertSemVer2PackagesIncludedInResult(IReadOnlyCollection <V2FeedPackage> resultSet, bool includePrerelease) { foreach (var package in SemVer2Packages.Where(p => p.IsPrerelease == includePrerelease)) { // Assert all of the SemVer2 packages are included in the result. // Whilst at it, also check the NormalizedVersion on the OData feed. Assert.Single(resultSet.Where(feedPackage => string.Equals(feedPackage.Version, package.Version) && string.Equals(feedPackage.NormalizedVersion, package.NormalizedVersion) && string.Equals(feedPackage.Id, package.PackageRegistration.Id))); } foreach (var package in NonSemVer2Packages.Where(p => p.IsPrerelease == includePrerelease)) { // Assert all of the non-SemVer2 packages are included in the result. // Whilst at it, also check the NormalizedVersion on the OData feed. Assert.Single(resultSet.Where(feedPackage => string.Equals(feedPackage.Version, package.Version) && string.Equals(feedPackage.NormalizedVersion, package.NormalizedVersion) && string.Equals(feedPackage.Id, package.PackageRegistration.Id))); } }