示例#1
0
        public void ConsolidateInstallsVersionsToHighestExisting()
        {
            // Arrange
            var tracing  = new TestTracing();
            var sut      = TestFixtureHelper.GetNuGetInstaller(true, false);
            var saved    = new List <(string path, string content)>();
            var project1 = TestFixtureHelper.CreateProject(VisualStudioProjectScheme.Lean, TestVersion.High, TestPackage.One, new Dictionary <string, string>());
            var project2 = TestFixtureHelper.CreateProject(VisualStudioProjectScheme.Lean, TestVersion.High, TestPackage.Two, new Dictionary <string, string>
            {
                { "TestPackage.One", "1.0.0" }
            });
            var projects = new[] { project1, project2 };

            // Act
            sut.Execute(projects, tracing, (path, content) => saved.Add((path, content)));

            // Assert
            Assert.Collection(saved, nuGetProject =>
            {
                Assert.Equal(project2.FilePath, nuGetProject.path);
                Assert.Equal(
                    XDocument.Parse(
                        @"<Project Sdk=""Microsoft.NET.Sdk"">

  <ItemGroup>
    <PackageReference Include=""TestPackage.One"" Version=""2.0.0"" />
    <PackageReference Include=""TestPackage.Two"" Version=""2.0.0"" />
  </ItemGroup>

</Project>", LoadOptions.PreserveWhitespace).ToString(),
                    nuGetProject.content);
            });
        }
示例#2
0
        public void GetInstalledPackagesReturnsEmptyCollection()
        {
            // Arrange
            var sut     = new UnsupportedSchemeProcessor();
            var project = TestFixtureHelper.CreateProject(VisualStudioProjectScheme.Unsupported, TestVersion.Low, TestPackage.One, new Dictionary <string, string>());

            // Act
            var installedPackages = sut.GetInstalledPackages(project.FilePath, null);

            // Assert
            Assert.Empty(installedPackages);
        }
示例#3
0
        public void ResolvesCorrectly(object untypedNuGetScheme)
        {
            var nuGetScheme = (VisualStudioProjectScheme)untypedNuGetScheme;

            // Arrange
            var project  = TestFixtureHelper.CreateProject(nuGetScheme, TestVersion.High, TestPackage.One, new Dictionary <string, string>());
            var document = XDocument.Load(project.FilePath);

            // Act
            var result = document.ResolveProjectScheme();

            // Assert
            Assert.Equal(nuGetScheme, result);
        }
示例#4
0
        public void ResolvesCorrectly(object untypedNuGetScheme)
        {
            var nuGetScheme = (NuGetScheme)untypedNuGetScheme;

            // Arrange
            var project  = TestFixtureHelper.CreateProject(nuGetScheme, TestVersion.High, TestPackage.One, new Dictionary <string, string>());
            var document = XDocument.Load(project.ProjectFile());

            // Act
            var result = NugetInstallerFactoryExtension.ResolveNuGetScheme(document.Root);

            // Assert
            Assert.Equal(nuGetScheme, result);
        }
        public void GetsInstalledPackages()
        {
            // Arrange
            var sut     = new LeanSchemeProcessor();
            var project = TestFixtureHelper.CreateProject(VisualStudioProjectScheme.Lean, TestVersion.Low, TestPackage.One, new Dictionary <string, string>());
            var doc     = XDocument.Load(project.FilePath);

            // Act
            var installedPackages = sut.GetInstalledPackages(project.FilePath, doc);

            // Assert
            Assert.Collection(installedPackages, x =>
            {
                Assert.Equal("TestPackage.One", x.Key);
                Assert.Equal(x.Value.Version, VersionRange.Parse("1.0.0"));
            });
        }
示例#6
0
        public void ConsolidatationNotTriggeredWhenVersionsAreTheSame()
        {
            // Arrange
            var tracing  = new TestTracing();
            var sut      = TestFixtureHelper.GetNuGetInstaller(true, false);
            var projects = new[]
            {
                TestFixtureHelper.CreateProject(VisualStudioProjectScheme.Lean, TestVersion.High, TestPackage.One, new Dictionary <string, string>()),
                TestFixtureHelper.CreateProject(VisualStudioProjectScheme.Lean, TestVersion.High, TestPackage.One, new Dictionary <string, string>()),
            };

            // Act
            sut.Execute(projects, tracing, (filePath, content) => { });

            // Assert
            Assert.Empty(tracing.InfoEntries);
        }
示例#7
0
        public void GetsInstalledPackages()
        {
            // Arrange
            var sut     = new VerboseWithPackageReferencesSchemeProcessor();
            var project = TestFixtureHelper.CreateProject(NuGetScheme.VerboseWithPackageReference, TestVersion.Low, TestPackage.One, new Dictionary <string, string>());
            var doc     = XDocument.Load(project.ProjectFile());

            // Act
            var installedPackages = sut.GetInstalledPackages(project, doc);

            // Assert
            Assert.Collection(installedPackages, x =>
            {
                Assert.Equal("TestPackage.One", x.Key);
                Assert.Equal(x.Value.Version, SemanticVersion.Parse("1.0.0"));
            });
        }