コード例 #1
0
        public void GivenARangeVerifyNU1608Warning(string yVersion, string yDepRange, string reason)
        {
            var testLogger = new TestLogger();
            var range      = VersionRange.Parse("1.0.0");
            var tfi        = GetTFI(NuGetFramework.Parse("net46"), new LibraryRange("x", range, LibraryDependencyTarget.Package));
            var project    = new PackageSpec(tfi)
            {
                Name = "proj"
            };

            var depY = new LibraryDependency()
            {
                LibraryRange = new LibraryRange("y", VersionRange.Parse(yDepRange), LibraryDependencyTarget.Package)
            };
            var itemX = GetItem("x", "1.0.0", LibraryType.Package, depY);
            var itemY = GetItem("y", yVersion, LibraryType.Package);

            var flattened = new HashSet <GraphItem <RemoteResolveResult> >()
            {
                itemX, itemY
            };
            var indexedGraphs = GetIndexedGraphs(flattened);

            var messages = UnexpectedDependencyMessages.GetDependenciesAboveUpperBounds(indexedGraphs, testLogger).ToList();
            var message  = messages.FirstOrDefault();

            messages.Count.Should().Be(1);
            message.LibraryId.Should().Be("y");
            message.TargetGraphs.Single().Should().Be("net46");
            message.Code.Should().Be(NuGetLogCode.NU1608, reason);
            message.Level.Should().Be(LogLevel.Warning);
        }
コード例 #2
0
        public void GivenAPackageVersionAboveADependencyConstraintVerifyWarning()
        {
            var testLogger = new TestLogger();
            var range      = VersionRange.Parse("1.0.0");
            var tfi        = GetTFI(NuGetFramework.Parse("net46"), new LibraryRange("x", range, LibraryDependencyTarget.Package));
            var project    = new PackageSpec(tfi)
            {
                Name = "proj"
            };

            var depY = new LibraryDependency()
            {
                LibraryRange = new LibraryRange("y", VersionRange.Parse("[1.0.0]"), LibraryDependencyTarget.Package)
            };
            var itemX = GetItem("x", "1.0.0", LibraryType.Package, depY);
            var itemY = GetItem("y", "2.0.0", LibraryType.Package);

            var flattened = new HashSet <GraphItem <RemoteResolveResult> >()
            {
                itemX, itemY
            };
            var indexedGraphs = GetIndexedGraphs(flattened);

            var messages = UnexpectedDependencyMessages.GetDependenciesAboveUpperBounds(indexedGraphs, testLogger).ToList();
            var message  = messages.FirstOrDefault();

            messages.Count.Should().Be(1);
            message.LibraryId.Should().Be("y");
            message.TargetGraphs.Single().Should().Be("net46");
            message.Message.Should().Be("Detected package version outside of dependency constraint: x 1.0.0 requires y (= 1.0.0) but version y 2.0.0 was resolved.");
            message.Code.Should().Be(NuGetLogCode.NU1608);
            message.Level.Should().Be(LogLevel.Warning);
        }
コード例 #3
0
        public void GivenAPackageVersionAboveMultipleDependencyConstraintsVerifyWarnings()
        {
            var testLogger = new TestLogger();
            var range      = VersionRange.Parse("1.0.0");
            var tfi        = GetTFI(NuGetFramework.Parse("net46"), new LibraryRange("x", range, LibraryDependencyTarget.Package));
            var project    = new PackageSpec(tfi)
            {
                Name = "proj"
            };

            var depYX = new LibraryDependency()
            {
                LibraryRange = new LibraryRange("y", VersionRange.Parse("[1.0.0]"), LibraryDependencyTarget.Package)
            };
            var depYZ = new LibraryDependency()
            {
                LibraryRange = new LibraryRange("y", VersionRange.Parse("[2.0.0]"), LibraryDependencyTarget.Package)
            };
            var itemX = GetItem("x", "1.0.0", LibraryType.Package, depYX);
            var itemY = GetItem("y", "3.0.0", LibraryType.Package);
            var itemZ = GetItem("z", "1.0.0", LibraryType.Package, depYZ);

            var flattened = new HashSet <GraphItem <RemoteResolveResult> >()
            {
                itemX, itemY, itemZ
            };
            var indexedGraphs = GetIndexedGraphs(flattened);

            var messages = UnexpectedDependencyMessages.GetDependenciesAboveUpperBounds(indexedGraphs, testLogger).ToList();

            messages.Count.Should().Be(2);
            messages.Select(e => e.Code).Distinct().Single().Should().Be(NuGetLogCode.NU1608);
        }
コード例 #4
0
        public void GivenAProjectVersionAboveADependencyConstraintVerifyNoWarning()
        {
            var testLogger = new TestLogger();
            var range      = VersionRange.Parse("1.0.0");
            var tfi        = GetTFI(NuGetFramework.Parse("net46"), new LibraryRange("x", range, LibraryDependencyTarget.Package));
            var project    = new PackageSpec(tfi)
            {
                Name = "proj"
            };

            var depY = new LibraryDependency()
            {
                LibraryRange = new LibraryRange("y", VersionRange.Parse("[1.0.0]"), LibraryDependencyTarget.Package)
            };
            var itemX = GetItem("x", "1.0.0", LibraryType.Package, depY);
            var itemY = GetItem("y", "2.0.0", LibraryType.Project);

            var flattened = new HashSet <GraphItem <RemoteResolveResult> >()
            {
                itemX, itemY
            };
            var indexedGraphs = GetIndexedGraphs(flattened);

            var messages = UnexpectedDependencyMessages.GetDependenciesAboveUpperBounds(indexedGraphs, testLogger).ToList();

            messages.Should().BeEmpty("project versions are not considered");
        }