Exemplo n.º 1
0
        public void GivenAProjectWithABumpedDependencyVerifyMessage()
        {
            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 flattened = new HashSet <GraphItem <RemoteResolveResult> >
            {
                new GraphItem <RemoteResolveResult>(new LibraryIdentity("X", NuGetVersion.Parse("2.0.0"), LibraryType.Package))
            };
            var targetGraph = new Mock <IRestoreTargetGraph>();

            targetGraph.SetupGet(e => e.Flattened).Returns(flattened);
            targetGraph.SetupGet(e => e.TargetGraphName).Returns("net46/win10");
            targetGraph.SetupGet(e => e.Framework).Returns(NuGetFramework.Parse("net46"));
            var targetGraphs = new[] { targetGraph.Object };
            var ignore       = new HashSet <string>();

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

            log.Code.Should().Be(NuGetLogCode.NU1601);
            log.TargetGraphs.ShouldBeEquivalentTo(new[] { "net46/win10" });
            log.Message.Should().Be("Dependency specified was x (>= 1.0.0) but ended up with X 2.0.0.");
        }
Exemplo n.º 2
0
        public void GivenAProjectWithABumpedDependencyThatIsIgnoredVerifyNoMessage()
        {
            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 flattened = new HashSet <GraphItem <RemoteResolveResult> >
            {
                new GraphItem <RemoteResolveResult>(new LibraryIdentity("x", NuGetVersion.Parse("2.0.0"), LibraryType.Package))
            };
            var targetGraph = new Mock <IRestoreTargetGraph>();

            targetGraph.SetupGet(e => e.Flattened).Returns(flattened);
            targetGraph.SetupGet(e => e.TargetGraphName).Returns("net46/win10");
            targetGraph.SetupGet(e => e.Framework).Returns(NuGetFramework.Parse("net46"));
            var targetGraphs = new[] { targetGraph.Object };
            var ignore       = new HashSet <string>()
            {
                "X"
            };

            UnexpectedDependencyMessages.GetBumpedUpDependencies(targetGraphs, project, ignore).Should().BeEmpty();
        }