public void GetFloatingDependencyVersions(string resourceName, string[] expected) { // Arrange var nuspec = Resources.LoadXml(resourceName); // Act var actual = NuspecUtility.GetFloatingDependencyVersions(nuspec); // Assert Assert.Equal(expected, actual); }
public bool IsMatch(XDocument nuspec) { var originalVersion = NuspecUtility.GetOriginalVersion(nuspec); if (!NuGetVersion.TryParse(originalVersion, out var parsedVersion)) { return(true); } return(false); }
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); }
public void GetUnsupportedDependencyTargetFrameworks(string resourceName, string[] expected) { // Arrange var nuspec = Resources.LoadXml(resourceName); // Act var actual = NuspecUtility.GetUnsupportedDependencyTargetFrameworks(nuspec); // Assert Assert.Equal(expected, actual); }
public void HasMixedDependencyGroupStyles(string resourceName, bool expected) { // Arrange var nuspec = Resources.LoadXml(resourceName); // Act var actual = NuspecUtility.HasMixedDependencyGroupStyles(nuspec); // Assert Assert.Equal(expected, actual); }
public bool IsMatch(XDocument nuspec) { var originalVersion = NuspecUtility.GetOriginalVersion(nuspec); if (originalVersion == null) { return(false); } return(ContainsWhitespace.IsMatch(originalVersion)); }
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); }
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); }
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 }); }
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); }
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); }
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)); }
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)); }
public bool IsMatch(XDocument nuspec) { return(NuspecUtility .GetWhitespaceDependencyVersions(nuspec) .Any()); }
public bool IsMatch(XDocument nuspec) { return(NuspecUtility .GetNonAlphabetMetadataElements(nuspec) .Any()); }
public bool IsMatch(XDocument nuspec) { return(NuspecUtility .GetInvalidDependencyIds(nuspec) .Any()); }
public bool IsMatch(XDocument nuspec) { return(NuspecUtility .GetDuplicateMetadataElements(nuspec, caseSensitive: true) .Any()); }
public bool IsMatch(XDocument nuspec) { var repositoryEl = NuspecUtility.GetRepository(nuspec); return(repositoryEl != null); }
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()); }
public bool IsMatch(XDocument nuspec) { return(NuspecUtility .GetMissingDependencyVersions(nuspec) .Any()); }
public bool IsMatch(XDocument nuspec) { return(NuspecUtility .GetDuplicateDependencies(nuspec) .Any()); }