Пример #1
0
        public async Task WhenFromPrereleaseIsAlwaysAllowedAndCurrentVersionIsPrerelease(
            bool latestPackageIsPrerelease,
            VersionChange dataRange,
            int expectedMajor, int expectedMinor, int expectedPatch, string expectedReleaseLabel)
        {
            var expectedUpdate = new NuGetVersion(expectedMajor, expectedMinor, expectedPatch, expectedReleaseLabel);
            var resultPackages = PackageVersionTestData.VersionsFor(dataRange);

            if (latestPackageIsPrerelease)
            {
                // Only grab updated prerelease packages for this test - otherwise we'll upgrade to 2.3.4 instead of 2.3.4-prerelease
                resultPackages = resultPackages.Where(x => x.Identity.Version.IsPrerelease).ToList();
            }
            var allVersionsLookup = MockVersionLookup(resultPackages);

            IApiPackageLookup lookup = new ApiPackageLookup(allVersionsLookup);

            var updates = await lookup.FindVersionUpdate(
                CurrentVersion123Prerelease("TestPackage"),
                NuGetSources.GlobalFeed,
                VersionChange.Major,
                UsePrerelease.Always);

            AssertPackagesIdentityIs(updates, "TestPackage");
            Assert.That(updates.Selected().Identity.Version, Is.EqualTo(expectedUpdate));
            Assert.That(updates.Major.Identity.Version, Is.EqualTo(HighestVersion(resultPackages)));
        }
Пример #2
0
        public async Task WhenPatchVersionChangesAreAllowed(VersionChange dataRange,
                                                            int expectedMajor, int expectedMinor, int expectedPatch)
        {
            var expectedUpdate    = new NuGetVersion(expectedMajor, expectedMinor, expectedPatch);
            var resultPackages    = PackageVersionTestData.VersionsFor(dataRange);
            var allVersionsLookup = MockVersionLookup(resultPackages);

            IApiPackageLookup lookup = new ApiPackageLookup(allVersionsLookup);

            var updates = await lookup.FindVersionUpdate(CurrentVersion123("TestPackage"),
                                                         VersionChange.Patch);

            AssertPackagesIdentityIs(updates, "TestPackage");
            Assert.That(updates.Selected().Identity.Version, Is.EqualTo(expectedUpdate));
            Assert.That(updates.Major.Identity.Version, Is.EqualTo(HighestVersion(resultPackages)));
        }
Пример #3
0
        public async Task WhenFromPrereleaseIsAllowedFromPrereleaseAndCurrentVersionIsStable(VersionChange dataRange,
                                                                                             int expectedMajor, int expectedMinor, int expectedPatch, string expectedReleaseLabel)
        {
            var expectedUpdate    = new NuGetVersion(expectedMajor, expectedMinor, expectedPatch, expectedReleaseLabel);
            var resultPackages    = PackageVersionTestData.VersionsFor(dataRange);
            var allVersionsLookup = MockVersionLookup(resultPackages);

            IApiPackageLookup lookup = new ApiPackageLookup(allVersionsLookup);

            var updates = await lookup.FindVersionUpdate(
                CurrentVersion123("TestPackage"),
                NuGetSources.GlobalFeed,
                VersionChange.Major,
                UsePrerelease.FromPrerelease);

            AssertPackagesIdentityIs(updates, "TestPackage");
            Assert.That(updates.Selected().Identity.Version, Is.EqualTo(expectedUpdate));
            Assert.That(updates.Major.Identity.Version, Is.EqualTo(HighestVersion(resultPackages)));
        }