コード例 #1
0
        private static void ApiHasNewVersionForPackage(IApiPackageLookup lookup, string packageName)
        {
            var responseMetaData = new PackageSearchMedatadata(
                new PackageIdentity(packageName, new NuGetVersion(2, 3, 4)), "test", DateTimeOffset.Now);

            lookup.FindVersionUpdate(Arg.Is <PackageIdentity>(pm => pm.Id == packageName), Arg.Any <VersionChange>())
            .Returns(new PackageLookupResult(VersionChange.Major, responseMetaData, responseMetaData, responseMetaData));
        }
コード例 #2
0
        public static PackageUpdateSet UpdateSetFor(PackageIdentity package, DateTimeOffset published, params PackageInProject[] packages)
        {
            var latest = new PackageSearchMedatadata(package, OfficialPackageSource(), published, null);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #3
0
        private static PackageUpdateSet UpdateSetFor(PackageIdentity package, DateTimeOffset published,
                                                     List <PackageInProject> packages, List <PackageDependency> deps)
        {
            var latest = new PackageSearchMedatadata(package, new PackageSource("http://none"), published, deps);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #4
0
        public static PackageUpdateSet UpdateSetFor(PackageVersionRange package, params PackageInProject[] packages)
        {
            var publishedDate = new DateTimeOffset(2018, 2, 19, 11, 12, 7, TimeSpan.Zero);
            var latest        = new PackageSearchMedatadata(package.SingleVersionIdentity(), new PackageSource("http://none"), publishedDate, null);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #5
0
        private static PackageUpdateSet UpdateSetForNewVersion(PackageIdentity newPackage, params PackageInProject[] packages)
        {
            var publishedDate = new DateTimeOffset(2018, 2, 19, 11, 12, 7, TimeSpan.Zero);
            var latest        = new PackageSearchMedatadata(newPackage, NugetSource, publishedDate);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #6
0
        private static PackageUpdateSet UpdateSetForInternalSource(params PackageInProject[] packages)
        {
            var newPackage    = NewPackageFooBar123();
            var publishedDate = new DateTimeOffset(2018, 2, 19, 11, 12, 7, TimeSpan.Zero);
            var latest        = new PackageSearchMedatadata(newPackage, "http://internalfeed.myco.com/api", publishedDate);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #7
0
        public static PackageUpdateSet ForInternalSource(params PackageInProject[] packages)
        {
            var newPackage    = new PackageIdentity("foo.bar", new NuGetVersion("1.2.3"));
            var publishedDate = new DateTimeOffset(2018, 2, 19, 11, 12, 7, TimeSpan.Zero);
            var latest        = new PackageSearchMedatadata(newPackage,
                                                            InternalPackageSource(), publishedDate, null);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #8
0
        public static PackageUpdateSet For(
            PackageIdentity package,
            DateTimeOffset published,
            IEnumerable <PackageInProject> packages,
            IEnumerable <PackageDependency> dependencies)
        {
            var latest  = new PackageSearchMedatadata(package, OfficialPackageSource(), published, dependencies);
            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #9
0
        private PackageUpdateSet BuildPackageUpdateSet(PackageInProject pip)
        {
            var package = new PackageIdentity(pip.Id, new NuGetVersion("1.4.5"));
            var latest  = new PackageSearchMedatadata(package, new PackageSource("http://none"), null, null);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, new List <PackageInProject> {
                pip
            }));
        }
コード例 #10
0
        private static PackageUpdateSet UpdateSetForLimited(DateTimeOffset?publishedAt, params PackageInProject[] packages)
        {
            var latestId = new PackageIdentity("foo.bar", new NuGetVersion("2.3.4"));
            var latest   = new PackageSearchMedatadata(latestId, NugetSource, publishedAt);

            var match = new PackageSearchMedatadata(
                NewPackageFooBar123(), NugetSource, null);

            var updates = new PackageLookupResult(VersionChange.Minor, latest, match, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #11
0
        public static PackageUpdateSet LimitedToMinor(DateTimeOffset?publishedAt,
                                                      params PackageInProject[] packages)
        {
            var latestId = new PackageIdentity("foo.bar", new NuGetVersion("2.3.4"));
            var latest   = new PackageSearchMedatadata(latestId, OfficialPackageSource(), publishedAt, null);

            var match = new PackageSearchMedatadata(
                new PackageIdentity("foo.bar", new NuGetVersion("1.2.3")), OfficialPackageSource(), null, null);

            var updates = new PackageLookupResult(VersionChange.Minor, latest, match, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #12
0
        public static PackageUpdateSet MakePackageUpdateSet(string packageName)
        {
            var fooPackage = new PackageIdentity(packageName, new NuGetVersion("1.2.3"));
            var latest     = new PackageSearchMedatadata(fooPackage, new PackageSource("http://none"), null,
                                                         Enumerable.Empty <PackageDependency>());
            var packages = new PackageLookupResult(VersionChange.Major, latest, null, null);

            var path = new PackagePath("c:\\foo", "bar", PackageReferenceType.ProjectFile);
            var pip  = new PackageInProject(fooPackage, path, null);

            return(new PackageUpdateSet(packages, new List <PackageInProject> {
                pip
            }));
        }
コード例 #13
0
        private static PackageUpdateSet UpdateSet(PackageReferenceType refType)
        {
            var fooPackage = new PackageIdentity("foo", new NuGetVersion(1, 2, 3));
            var path       = new PackagePath("c:\\foo", "bar", refType);
            var packages   = new[]
            {
                new PackageInProject(fooPackage, path, null)
            };

            var latest = new PackageSearchMedatadata(fooPackage, new PackageSource(NuGetConstants.V3FeedUrl), null, null);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #14
0
        private static PackageUpdateSet UpdateFoobarFromOneVersion()
        {
            var newPackage = LatestVersionOfPackageFoobar();

            var currentPackages = new List<PackageInProject>
            {
                new PackageInProject("foobar", "1.0.1", PathToProjectOne()),
                new PackageInProject("foobar", "1.0.1", PathToProjectTwo())
            };

            var latest = new PackageSearchMedatadata(newPackage, new PackageSource("http://none"), DateTimeOffset.Now, null);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);
            return new PackageUpdateSet(updates, currentPackages);
        }
コード例 #15
0
        private static PackageUpdateSet UpdateSet()
        {
            PackageIdentity fooPackage = new PackageIdentity("foo", new NuGetVersion(1, 2, 3));
            var             packages   = new[]
            {
                new PackageInProject(fooPackage, new PackagePath("c:\\foo", "bar", PackageReferenceType.PackagesConfig))
            };

            var publishedDate = new DateTimeOffset(2018, 2, 19, 11, 12, 7, TimeSpan.Zero);
            var latest        = new PackageSearchMedatadata(fooPackage, new PackageSource("https://somewhere"), publishedDate, null);

            var updates = new PackageLookupResult(VersionChange.Major, latest, null, null);

            return(new PackageUpdateSet(updates, packages));
        }
コード例 #16
0
        private static PackageUpdateSet UpdateBarFromTwoVersions(TimeSpan? packageAge = null)
        {
            var pubDate = DateTimeOffset.Now.Subtract(packageAge ?? TimeSpan.Zero);

            var currentPackages = new List<PackageInProject>
            {
                new PackageInProject("bar", "1.0.1", PathToProjectOne()),
                new PackageInProject("bar", "1.2.1", PathToProjectTwo())
            };

            var matchId = new PackageIdentity("bar", new NuGetVersion("4.0.0"));
            var match = new PackageSearchMedatadata(matchId, new PackageSource("http://none"), pubDate, null);

            var updates = new PackageLookupResult(VersionChange.Major, match, null, null);
            return new PackageUpdateSet(updates, currentPackages);
        }
コード例 #17
0
        private PackageUpdateSet UpdateFooFromOneVersion(TimeSpan?packageAge = null)
        {
            var pubDate = DateTimeOffset.Now.Subtract(packageAge ?? TimeSpan.Zero);

            var currentPackages = new List <PackageInProject>
            {
                new PackageInProject("foo", "1.0.1", PathToProjectOne()),
                new PackageInProject("foo", "1.0.1", PathToProjectTwo())
            };

            var matchVersion = new NuGetVersion("4.0.0");
            var match        = new PackageSearchMedatadata(new PackageIdentity("foo", matchVersion), "ASource", pubDate);

            var updates = new PackageLookupResult(VersionChange.Major, match, null, null);

            return(new PackageUpdateSet(updates, currentPackages));
        }
コード例 #18
0
        public static PackageUpdateSet MakeUpdateSet(string packageName,
                                                     string version = "1.2.3",
                                                     PackageReferenceType packageRefType = PackageReferenceType.ProjectFile)
        {
            var packageId = new PackageIdentity(packageName, new NuGetVersion(version));
            var latest    = new PackageSearchMedatadata(
                packageId, OfficialPackageSource(),
                null,
                Enumerable.Empty <PackageDependency>());

            var packages = new PackageLookupResult(VersionChange.Major, latest, null, null);

            var pip = new PackageInProject(packageId, MakePackagePath(packageRefType), null)
                      .InList();

            return(new PackageUpdateSet(packages, pip));
        }
コード例 #19
0
        private PackageUpdateSet UpdateBarFromTwoVersions()
        {
            var newPackage = LatestVersionOfPackageBar();

            var currentPackages = new List <PackageInProject>
            {
                new PackageInProject("bar", "1.0.1", PathToProjectOne()),
                new PackageInProject("bar", "1.2.1", PathToProjectTwo())
            };

            var matchId = new PackageIdentity("bar", new NuGetVersion("4.0.0"));
            var match   = new PackageSearchMedatadata(matchId, "ASource", DateTimeOffset.Now);

            var updates = new PackageLookupResult(VersionChange.Major, match, null, null);

            return(new PackageUpdateSet(updates, currentPackages));
        }
コード例 #20
0
        public void WhenThereIsAMajorUpdate()
        {
            var logger   = Substitute.For <INuKeeperLogger>();
            var reporter = new PackageLookupResultReporter(logger);

            var fooMetadata = new PackageSearchMedatadata(
                new PackageIdentity("foo", new NuGetVersion(2, 3, 4)),
                new PackageSource("http://none"), DateTimeOffset.Now, null);

            var data = new PackageLookupResult(VersionChange.Major, fooMetadata, fooMetadata, fooMetadata);

            reporter.Report(data);

            logger.Received()
            .Detailed("Selected update of package foo to highest version, 2.3.4.");
            logger.DidNotReceive().Error(Arg.Any <string>());
            logger.DidNotReceive().Minimal(Arg.Any <string>());
            logger.DidNotReceive().Normal(Arg.Any <string>());
        }
コード例 #21
0
        public void WhenThereIsAMajorUpdateThatCannotBeUsed()
        {
            var logger   = Substitute.For <INuKeeperLogger>();
            var reporter = new PackageLookupResultReporter(logger);

            var fooMajor = new PackageSearchMedatadata(
                new PackageIdentity("foo", new NuGetVersion(3, 0, 0)),
                new PackageSource("http://none"), DateTimeOffset.Now, null);

            var data = new PackageLookupResult(VersionChange.Minor, fooMajor, null, null);

            reporter.Report(data);

            logger.Received()
            .Normal("Package foo version 3.0.0 is available but is not allowed. Allowing Minor version updates.");
            logger.DidNotReceive().Error(Arg.Any <string>());
            logger.DidNotReceive().Minimal(Arg.Any <string>());
            logger.DidNotReceive().Detailed(Arg.Any <string>());
        }
コード例 #22
0
        private static string PackageVersionAndDate(NuGetVersion baseline, PackageSearchMedatadata packageVersion)
        {
            const string none = ",";

            if (packageVersion == null)
            {
                return(none);
            }

            if (packageVersion.Identity.Version <= baseline)
            {
                return(none);
            }

            var version = packageVersion.Identity.Version;
            var date    = DateFormat.AsUtcIso8601(packageVersion.Published);

            return($"{version},{date}");
        }
コード例 #23
0
        public void WhenThereIsAMinorUpdate()
        {
            var logger   = Substitute.For <INuKeeperLogger>();
            var reporter = new PackageLookupResultReporter(logger);

            var fooMetadata = new PackageSearchMedatadata(
                new PackageIdentity("foo", new NuGetVersion(2, 3, 4)),
                "someSource", DateTimeOffset.Now);

            var data = new PackageLookupResult(VersionChange.Minor, fooMetadata, fooMetadata, fooMetadata);

            reporter.Report(data);

            logger.Received()
            .Verbose("Selected update of package foo to highest version, 2.3.4. Allowing Minor version updates.");

            logger.DidNotReceive().Error(Arg.Any <string>());
            logger.DidNotReceive().Terse(Arg.Any <string>());
            logger.DidNotReceive().Info(Arg.Any <string>());
        }
コード例 #24
0
        public void WhenThereIsAMajorAndAMinorUpdate()
        {
            var logger   = Substitute.For <INuKeeperLogger>();
            var reporter = new PackageLookupResultReporter(logger);

            var fooMajor = new PackageSearchMedatadata(
                new PackageIdentity("foo", new NuGetVersion(3, 0, 0)),
                new PackageSource("http://none"), DateTimeOffset.Now, null);
            var fooMinor = new PackageSearchMedatadata(
                new PackageIdentity("foo", new NuGetVersion(2, 3, 4)),
                new PackageSource("http://none"), DateTimeOffset.Now, null);

            var data = new PackageLookupResult(VersionChange.Minor, fooMajor, fooMinor, null);

            reporter.Report(data);

            logger.Received()
            .Info("Selected update of package foo to version 2.3.4, but version 3.0.0 is also available. Allowing Minor version updates.");
            logger.DidNotReceive().Error(Arg.Any <string>());
            logger.DidNotReceive().Terse(Arg.Any <string>());
            logger.DidNotReceive().Verbose(Arg.Any <string>());
        }
コード例 #25
0
        public void OneUpdate_IsValid()
        {
            var fooVersionFour = new PackageIdentity("foo", VersionFour());
            var highest        = new PackageSearchMedatadata(fooVersionFour, _source, DateTimeOffset.Now, null);

            var currentPackages = new List <PackageInProject>
            {
                new PackageInProject("foo", "1.0.0", PathToProjectOne())
            };

            var lookupResult = new PackageLookupResult(VersionChange.Major, highest, null, null);
            var updates      = new PackageUpdateSet(lookupResult, currentPackages);

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

            Assert.That(updates.Packages.Major?.Identity.Version, Is.EqualTo(VersionFour()));
            Assert.That(updates.AllowedChange, Is.EqualTo(VersionChange.Major));

            Assert.That(updates.Selected, Is.Not.Null);
            Assert.That(updates.Selected.Identity, Is.EqualTo(fooVersionFour));
            Assert.That(updates.SelectedId, Is.EqualTo("foo"));
            Assert.That(updates.SelectedVersion, Is.EqualTo(highest.Identity.Version));
            Assert.That(updates.Selected.Source, Is.EqualTo(_source));
        }
コード例 #26
0
 private static void AssertPackageIdentityIs(PackageSearchMedatadata package, string id)
 {
     Assert.That(package, Is.Not.Null);
     Assert.That(package.Identity, Is.Not.Null);
     Assert.That(package.Identity.Id, Is.EqualTo(id));
 }
コード例 #27
0
        private static PackageSearchMedatadata FilteredPackageVersion(NuGetVersion baseline, PackageSearchMedatadata packageVersion)
        {
            if (packageVersion == null)
            {
                return(null);
            }

            if (packageVersion.Identity.Version <= baseline)
            {
                return(null);
            }

            return(packageVersion);
        }