示例#1
0
        public void GivenAGraphWithMultipleIssuesForTheSamePackageVerifyBothMessagesLogged()
        {
            var parent1       = new LibraryIdentity("x", NuGetVersion.Parse("9.0.0"), LibraryType.Package);
            var parent2       = new LibraryIdentity("y", NuGetVersion.Parse("8.0.0"), LibraryType.Package);
            var child1        = new LibraryIdentity("b", NuGetVersion.Parse("2.0.0"), LibraryType.Package);
            var child2        = new LibraryIdentity("b", NuGetVersion.Parse("3.0.0"), LibraryType.Package);
            var dependency1   = new ResolvedDependencyKey(parent1, VersionRange.Parse("(, 5.0.0]"), child1);
            var dependency2   = new ResolvedDependencyKey(parent2, VersionRange.Parse("(1.0.0, 6.0.0]"), child2);
            var dependencySet = new HashSet <ResolvedDependencyKey>()
            {
                dependency1, dependency2
            };
            var targetGraph = new Mock <IRestoreTargetGraph>();

            targetGraph.SetupGet(e => e.ResolvedDependencies).Returns(dependencySet);
            targetGraph.SetupGet(e => e.TargetGraphName).Returns("net46/win10");
            var targetGraphs = new[] { targetGraph.Object };
            var ignore       = new HashSet <string>();

            var logs = UnexpectedDependencyMessages.GetMissingLowerBounds(targetGraphs, ignore).ToList();

            logs.Select(e => e.Message).ShouldBeEquivalentTo(new[]
            {
                "x 9.0.0 does not provide an inclusive lower bound for dependency b (<= 5.0.0). An approximate best match of b 2.0.0 was resolved.",
                "y 8.0.0 does not provide an inclusive lower bound for dependency b (> 1.0.0 && <= 6.0.0). An approximate best match of b 3.0.0 was resolved."
            });
        }
示例#2
0
        public void GivenAGraphIsMissingALowerBoundVerifyWarningIncludesGraphName()
        {
            var range         = VersionRange.Parse("(, 5.0.0]");
            var parent        = new LibraryIdentity("a", NuGetVersion.Parse("9.0.0"), LibraryType.Package);
            var child         = new LibraryIdentity("b", NuGetVersion.Parse("2.0.0"), LibraryType.Package);
            var dependency    = new ResolvedDependencyKey(parent, range, child);
            var dependencySet = new HashSet <ResolvedDependencyKey>()
            {
                dependency
            };
            var targetGraph = new Mock <IRestoreTargetGraph>();

            targetGraph.SetupGet(e => e.ResolvedDependencies).Returns(dependencySet);
            targetGraph.SetupGet(e => e.TargetGraphName).Returns("net46/win10");
            var targetGraphs = new[] { targetGraph.Object };
            var ignore       = new HashSet <string>();

            var log = UnexpectedDependencyMessages.GetMissingLowerBounds(targetGraphs, ignore).Single();

            log.TargetGraphs.ShouldBeEquivalentTo(new[] { "net46/win10" });
            log.Code.Should().Be(NuGetLogCode.NU1602);
        }
示例#3
0
        public void GivenAGraphIsMissingALowerBoundAndIdIsIgnoredVerifyWarningSkipped()
        {
            var range         = VersionRange.Parse("(, 5.0.0]");
            var parent        = new LibraryIdentity("a", NuGetVersion.Parse("9.0.0"), LibraryType.Package);
            var child         = new LibraryIdentity("b", NuGetVersion.Parse("2.0.0"), LibraryType.Package);
            var dependency    = new ResolvedDependencyKey(parent, range, child);
            var dependencySet = new HashSet <ResolvedDependencyKey>()
            {
                dependency
            };
            var targetGraph = new Mock <IRestoreTargetGraph>();

            targetGraph.SetupGet(e => e.ResolvedDependencies).Returns(dependencySet);
            targetGraph.SetupGet(e => e.TargetGraphName).Returns("net46/win10");
            var targetGraphs = new[] { targetGraph.Object };
            var ignore       = new HashSet <string>()
            {
                "B"
            };

            var logs = UnexpectedDependencyMessages.GetMissingLowerBounds(targetGraphs, ignore);

            logs.Should().BeEmpty();
        }