public void AddShortFormOfDependencyVersionRange(string input, string expected) { var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion, DependencyGroups = new List <PackageDependencyGroup> { new PackageDependencyGroup { TargetFramework = "net40", Dependencies = new List <Protocol.Catalog.PackageDependency> { new Protocol.Catalog.PackageDependency { Id = "NuGet.Versioning", Range = input } }, }, }, }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Equal("NuGet.Versioning:" + expected + ":net40", full.FlattenedDependencies); }
public void DoesNotIncludeDependencyVersionSpecialFrameworks(string framework) { var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion, DependencyGroups = new List <PackageDependencyGroup> { new PackageDependencyGroup { TargetFramework = framework, Dependencies = new List <Protocol.Catalog.PackageDependency> { new Protocol.Catalog.PackageDependency { Id = "NuGet.Versioning", Range = "2.0.0", }, new Protocol.Catalog.PackageDependency { Id = "NuGet.Frameworks", Range = "3.0.0", }, }, }, }, }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Equal("NuGet.Versioning:2.0.0|NuGet.Frameworks:3.0.0", full.FlattenedDependencies); }
public void AddsEmptyStringForDependencyVersionAllRange() { var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion, DependencyGroups = new List <PackageDependencyGroup> { new PackageDependencyGroup { TargetFramework = "net40", Dependencies = new List <Protocol.Catalog.PackageDependency> { new Protocol.Catalog.PackageDependency { Id = "NuGet.Versioning", Range = "(, )" } }, }, }, }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Equal("NuGet.Versioning::net40", full.FlattenedDependencies); }
private static void VerifyFieldsDependingOnId(string expected, HijackDocument.Full full) { Assert.Equal(expected, full.PackageId); Assert.Equal(expected, full.TokenizedPackageId); Assert.Equal(expected, full.Title); Assert.Equal($"{Data.GalleryBaseUrl}packages/{expected}/{Data.NormalizedVersion}/license", full.LicenseUrl); Assert.Equal($"{Data.FlatContainerBaseUrl}{Data.FlatContainerContainerName}/{Data.LowerPackageId}/{Data.LowerNormalizedVersion}/icon", full.IconUrl); }
public void AllowNullDependencyGroups() { var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion, DependencyGroups = null }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Null(full.FlattenedDependencies); }
public void IfPackageDoesNotHaveAnyIconFile_NoIconUrlIsSet() { Config.AllIconsInFlatContainer = true; var package = new Package { NormalizedVersion = Data.NormalizedVersion, }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.PackageId, package); Assert.Null(full.IconUrl); }
public void IfPackageHasEmbeddedIcon_LinksToFlatContainer() { var package = new Package { NormalizedVersion = Data.NormalizedVersion, IconUrl = "iconUrl", HasEmbeddedIcon = true }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.PackageId, package); Assert.Equal(Data.FlatContainerIconUrl, full.IconUrl); }
public void IfLeafDoesNotHaveAnyIconFile_NoIconUrlIsSet() { Config.AllIconsInFlatContainer = true; var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Null(full.IconUrl); }
public void IfPackageDoesNotHaveIconFileButHasUrl_UsesFlatContainerIfConfigured() { Config.AllIconsInFlatContainer = true; var package = new Package { NormalizedVersion = Data.NormalizedVersion, IconUrl = "iconUrl" }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.PackageId, package); Assert.Equal(Data.FlatContainerIconUrl, full.IconUrl); }
public void UsesProvidedPackageId() { var package = new Package { NormalizedVersion = Data.NormalizedVersion, LicenseExpression = "Unlicense", HasEmbeddedIcon = true, }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.PackageId, package); VerifyFieldsDependingOnId(Data.PackageId, full); }
public void IfPackageDoesNotHaveEmbeddedIcon_UsesIconUrl() { var iconUrl = "iconUrl"; var package = new Package { NormalizedVersion = Data.NormalizedVersion, IconUrl = iconUrl }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.PackageId, package); Assert.Equal(iconUrl, full.IconUrl); }
public void IfLeafHasIconFile_LinksToFlatContainer() { var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion, IconFile = "iconFile", IconUrl = "iconUrl" }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Equal(Data.FlatContainerIconUrl, full.IconUrl); }
public void IfLeafDoesNotHaveIconFile_UsesIconUrl() { var iconUrl = "iconUrl"; var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion, IconUrl = iconUrl }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Equal(iconUrl, full.IconUrl); }
public HijackDocument.Full FullFromCatalog( string normalizedVersion, HijackDocumentChanges changes, PackageDetailsCatalogLeaf leaf) { var document = new HijackDocument.Full(); PopulateLatest( document, leaf.PackageId, normalizedVersion, lastUpdatedFromCatalog: true, lastCommitTimestamp: leaf.CommitTimestamp, lastCommitId: leaf.CommitId, changes: changes); _baseDocumentBuilder.PopulateMetadata(document, normalizedVersion, leaf); document.Listed = leaf.IsListed(); return(document); }
public void PrefersPackageRegistrationIdOverProvidedId() { var expected = "windowsazure.STORAGE"; var package = new Package { PackageRegistration = new PackageRegistration { Id = expected, }, NormalizedVersion = Data.NormalizedVersion, LicenseExpression = "Unlicense", HasEmbeddedIcon = true, }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.PackageId, package); VerifyFieldsDependingOnId(expected, full); }
public void AddsEmptyDependencyGroup(string framework, string expected) { var leaf = new PackageDetailsCatalogLeaf { PackageId = Data.PackageId, PackageVersion = Data.NormalizedVersion, DependencyGroups = new List <PackageDependencyGroup> { new PackageDependencyGroup { TargetFramework = framework, }, }, }; var full = new HijackDocument.Full(); Target.PopulateMetadata(full, Data.NormalizedVersion, leaf); Assert.Equal(expected, full.FlattenedDependencies); }
public HijackDocument.Full FullFromDb( string packageId, HijackDocumentChanges changes, Package package) { var document = new HijackDocument.Full(); PopulateLatest( document, packageId, lastUpdatedFromCatalog: false, lastCommitTimestamp: null, lastCommitId: null, normalizedVersion: package.NormalizedVersion, changes: changes); _baseDocumentBuilder.PopulateMetadata(document, packageId, package); document.Listed = package.Listed; return(document); }