예제 #1
0
            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);
            }
예제 #2
0
            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);
            }
예제 #3
0
            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);
 }
예제 #5
0
            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);
            }
예제 #6
0
            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);
            }
예제 #7
0
            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);
            }
예제 #8
0
            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);
            }
예제 #9
0
            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);
            }
예제 #11
0
            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);
            }
예제 #12
0
            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);
            }
예제 #13
0
            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);
            }
예제 #14
0
        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);
            }
예제 #16
0
            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);
            }
예제 #17
0
        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);
        }