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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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 })); }
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)); }
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)); }
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 })); }
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)); }
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); }
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)); }
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); }
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)); }
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)); }
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)); }
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>()); }
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>()); }
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}"); }
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>()); }
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>()); }
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)); }
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)); }
private static PackageSearchMedatadata FilteredPackageVersion(NuGetVersion baseline, PackageSearchMedatadata packageVersion) { if (packageVersion == null) { return(null); } if (packageVersion.Identity.Version <= baseline) { return(null); } return(packageVersion); }