Esempio n. 1
0
        public void GetFloatingDependencyVersions(string resourceName, string[] expected)
        {
            // Arrange
            var nuspec = Resources.LoadXml(resourceName);

            // Act
            var actual = NuspecUtility.GetFloatingDependencyVersions(nuspec);

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 2
0
        public bool IsMatch(XDocument nuspec)
        {
            var originalVersion = NuspecUtility.GetOriginalVersion(nuspec);

            if (!NuGetVersion.TryParse(originalVersion, out var parsedVersion))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public void GetDuplicateDependencies(string resourceName, ILookup <NuGetFramework, string> expected)
        {
            // Arrange
            var nuspec = Resources.LoadXml(resourceName);

            // Act
            var actual = NuspecUtility.GetDuplicateDependencies(nuspec);

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 4
0
        public void GetUnsupportedDependencyTargetFrameworks(string resourceName, string[] expected)
        {
            // Arrange
            var nuspec = Resources.LoadXml(resourceName);

            // Act
            var actual = NuspecUtility.GetUnsupportedDependencyTargetFrameworks(nuspec);

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 5
0
        public void HasMixedDependencyGroupStyles(string resourceName, bool expected)
        {
            // Arrange
            var nuspec = Resources.LoadXml(resourceName);

            // Act
            var actual = NuspecUtility.HasMixedDependencyGroupStyles(nuspec);

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 6
0
        public bool IsMatch(XDocument nuspec)
        {
            var originalVersion = NuspecUtility.GetOriginalVersion(nuspec);

            if (originalVersion == null)
            {
                return(false);
            }

            return(ContainsWhitespace.IsMatch(originalVersion));
        }
Esempio n. 7
0
        public bool IsMatch(XDocument nuspec)
        {
            var originalVersion = NuspecUtility.GetOriginalVersion(nuspec);

            if (NuGetVersion.TryParse(originalVersion, out var parsedVersion))
            {
                var normalizedVersion = parsedVersion.ToFullString();
                return(!StringComparer.OrdinalIgnoreCase.Equals(originalVersion, normalizedVersion));
            }

            return(false);
        }
Esempio n. 8
0
        public void HasNonAlphabetMetadataElements()
        {
            // Arrange
            var nuspec = Resources.LoadXml(Resources.Nuspecs.NonAlphabetMetadataElements);

            // Act
            var output = NuspecUtility.GetNonAlphabetMetadataElements(nuspec);

            // Assert
            Assert.Equal(
                new[] { "author_", "author.2", "files-1" },
                output);
        }
Esempio n. 9
0
        public void GetUnexpectedValuesForBooleanMetadata()
        {
            // Arrange
            var nuspec = Resources.LoadXml(Resources.Nuspecs.UnexpectedValuesForBooleans);

            // Act
            var output = NuspecUtility.GetUnexpectedValuesForBooleanMetadata(nuspec);

            // Assert
            Assert.Equal(2, output.Count);
            Assert.Equal(output["requireLicenseAcceptance"], new[] { "0", "1" });
            Assert.Equal(output["serviceable"], new[] { string.Empty, string.Empty });
        }
Esempio n. 10
0
        public bool IsMatch(XDocument nuspec)
        {
            var metadataEl = NuspecUtility.GetMetadata(nuspec);

            if (metadataEl == null)
            {
                return(false);
            }

            var ns             = metadataEl.GetDefaultNamespace();
            var packageTypesEl = metadataEl.Element(ns.GetName("packageTypes"));

            return(packageTypesEl != null);
        }
Esempio n. 11
0
        public void HasDuplicateMetadataElementsCaseSensitive()
        {
            // Arrange
            var nuspec = Resources.LoadXml(Resources.Nuspecs.DuplicateMetadataElements);

            // Act
            var output = NuspecUtility.GetDuplicateMetadataElements(nuspec, caseSensitive: true);

            // Assert
            Assert.NotEmpty(output);
            Assert.Equal(new[] { "authors", "dependencies", "owners" }, output.Keys.OrderBy(x => x));
            Assert.Equal(3, output["authors"]);
            Assert.Equal(2, output["dependencies"]);
            Assert.Equal(2, output["owners"]);
        }
        private async Task InitializeItemAsync(List <PackageDependencyGroups> output, PackageEntity package)
        {
            var nuspec = await _nuspecStore.GetNuspecContextAsync(package.PackageRegistration.Id, package.Version);

            if (nuspec.Document == null)
            {
                return;
            }

            var identity                = new PackageIdentity(package.PackageRegistration.Id, package.Version);
            var dependencyGroups        = NuspecUtility.GetParsedDependencyGroups(nuspec.Document);
            var packageDependencyGroups = new PackageDependencyGroups(identity, dependencyGroups);

            output.Add(packageDependencyGroups);
        }
Esempio n. 13
0
        public void HasCollidingMetadataElements()
        {
            // Arrange
            var nuspec = Resources.LoadXml(Resources.Nuspecs.CollidingMetadataElements);

            // Act
            var output = NuspecUtility.GetCollidingMetadataElements(nuspec);

            // Assert
            Assert.Equal(
                new[]
            {
                "created", "dependencyGroups", "isPrerelease", "lastEdited", "listed", "packageEntries",
                "packageHash", "packageHashAlgorithm", "packageSize", "published", "supportedFrameworks",
                "verbatimVersion",
            },
                output);
        }
        public bool IsMatch(XDocument nuspec)
        {
            var metadataEl = NuspecUtility.GetMetadata(nuspec);

            if (metadataEl == null)
            {
                return(false);
            }

            var ns   = metadataEl.GetDefaultNamespace();
            var idEl = metadataEl.Element(ns.GetName("id"));

            if (idEl == null)
            {
                return(false);
            }

            var id = idEl.Value.TrimEnd();

            return(EndsInDotNumber.IsMatch(id));
        }
Esempio n. 15
0
        public async Task <PackageQueryContext> GetPackageQueryFromDatabasePackageContextAsync(PackageEntity package)
        {
            var immutablePackage   = new ImmutablePackage(package);
            var nuspecQueryContext = await GetNuspecQueryContextAsync(package);

            var isSemVer2 = NuspecUtility.IsSemVer2(nuspecQueryContext.Document);

            var    originalVersion = NuspecUtility.GetOriginalVersion(nuspecQueryContext.Document);
            string fullVersion     = null;

            if (NuGetVersion.TryParse(originalVersion, out var parsedVersion))
            {
                fullVersion = parsedVersion.ToFullString();
            }

            return(new PackageQueryContext(
                       immutablePackage,
                       nuspecQueryContext,
                       isSemVer2,
                       fullVersion,
                       package.V2Package?.Listed ?? package.CatalogPackage?.Listed ?? true));
        }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility.HasMixedDependencyGroupStyles(nuspec));
 }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility.HasSemVer2DependencyVersion(nuspec));
 }
Esempio n. 18
0
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetWhitespaceDependencyVersions(nuspec)
            .Any());
 }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetNonAlphabetMetadataElements(nuspec)
            .Any());
 }
Esempio n. 20
0
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetInvalidDependencyIds(nuspec)
            .Any());
 }
Esempio n. 21
0
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetDuplicateMetadataElements(nuspec, caseSensitive: true)
            .Any());
 }
Esempio n. 22
0
        public bool IsMatch(XDocument nuspec)
        {
            var repositoryEl = NuspecUtility.GetRepository(nuspec);

            return(repositoryEl != null);
        }
Esempio n. 23
0
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetDuplicateNormalizedDependencyTargetFrameworks(nuspec)
            .Any());
 }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetUnsupportedDependencyTargetFrameworks(nuspec)
            .Any());
 }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetCollidingMetadataElements(nuspec)
            .Any());
 }
        public bool IsMatch(XDocument nuspec)
        {
            var id = NuspecUtility.GetOriginalId(nuspec);

            return(!StrictPackageIdValidator.IsValid(id));
        }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetWhitespaceDependencyTargetFrameworks(nuspec)
            .Any());
 }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetUnexpectedValuesForBooleanMetadata(nuspec)
            .Any());
 }
Esempio n. 29
0
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetMissingDependencyVersions(nuspec)
            .Any());
 }
 public bool IsMatch(XDocument nuspec)
 {
     return(NuspecUtility
            .GetDuplicateDependencies(nuspec)
            .Any());
 }