Exemple #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)));
        }
Exemple #2
0
        public async Task WhenNoPackagesAreFound()
        {
            var allVersionsLookup    = MockVersionLookup(new List <PackageSearchMedatadata>());
            IApiPackageLookup lookup = new ApiPackageLookup(allVersionsLookup);

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

            Assert.That(updates, Is.Not.Null);
            Assert.That(updates.Major, Is.Null);
            Assert.That(updates.Selected(), Is.Null);
        }
Exemple #3
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)));
        }
Exemple #4
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)));
        }
Exemple #5
0
        public async Task WhenThereIsOnlyOneVersion()
        {
            var resultPackages = new List <PackageSearchMedatadata>
            {
                PackageVersionTestData.PackageVersion(2, 3, 4)
            };

            var allVersionsLookup = MockVersionLookup(resultPackages);

            IApiPackageLookup lookup = new ApiPackageLookup(allVersionsLookup);

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

            Assert.That(updates, Is.Not.Null);

            AssertPackagesIdentityIs(updates, "TestPackage");
            Assert.That(updates.Major.Identity.Version, Is.EqualTo(new NuGetVersion(2, 3, 4)));
            Assert.That(updates.Selected().Identity.Version, Is.EqualTo(new NuGetVersion(2, 3, 4)));
        }