Ejemplo n.º 1
0
        public void SingleDependencyListedInManifestDependencies()
        {
            var singleDependency                = ProjectReferenceTestData.ConstructMockDependency();
            var projectWithSingleDependency     = ProjectReferenceTestData.ConstructMockProject(new[] { singleDependency.Object });
            var packageRepositoryWithOnePackage = ProjectReferenceTestData.CreateMockRepository();

            var nugetifier           = ReferenceNugetifierTester.BuildNugetifier(vsProject: projectWithSingleDependency, packageRepository: packageRepositoryWithOnePackage);
            var nugettedDependencies = ReferenceNugetifierTester.NugetifyReferencesInProject(nugetifier);

            Assert.That(nugettedDependencies, Is.Not.Empty);
            Assert.That(nugettedDependencies.Single().Id, Contains.Substring(ProjectReferenceTestData.PackageInRepository));
        }
Ejemplo n.º 2
0
        public void TwoDependenciesWithCorrespondingPackagesGetNugetted()
        {
            var defaultDependency           = ProjectReferenceTestData.ConstructMockDependency(ProjectReferenceTestData.AssemblyFilenameInPackageRepository);
            var secondDependency            = ProjectReferenceTestData.ConstructMockDependency(ProjectReferenceTestData.AnotherAssemblyInPackageRepository);
            var projectWithSingleDependency = ProjectReferenceTestData.ConstructMockProject(new[] { defaultDependency.Object, secondDependency.Object });
            var packageRepositoryWithCorrespondingPackage = ProjectReferenceTestData.CreateMockRepository();

            var nugetifier = ReferenceNugetifierTester.BuildNugetifier(vsProject: projectWithSingleDependency, packageRepository: packageRepositoryWithCorrespondingPackage);

            ReferenceNugetifierTester.NugetifyReferencesInProject(nugetifier);
            defaultDependency.Verify(d => d.ConvertToNugetReferenceWithHintPath(It.IsAny <string>()), Times.Once());
            secondDependency.Verify(d => d.ConvertToNugetReferenceWithHintPath(It.IsAny <string>()), Times.Once());
        }
Ejemplo n.º 3
0
        public void NugettedProjectHasPackagesConfigAddedToRepositoriesConfig()
        {
            const string projectRoot                     = "c:\\projectRoot";
            var          fileSystem                      = new MockFileSystem(projectRoot);
            var          singleDependency                = ProjectReferenceTestData.ConstructMockDependency();
            var          projectWithSingleDependency     = ProjectReferenceTestData.ConstructMockProject(new[] { singleDependency.Object });
            var          packageRepositoryWithOnePackage = ProjectReferenceTestData.CreateMockRepository();
            var          repositoriesConfig              = new Mock <ISharedPackageRepository>();

            var nugetifier           = ReferenceNugetifierTester.BuildNugetifier(vsProject: projectWithSingleDependency, packageRepository: packageRepositoryWithOnePackage, projectFileSystem: fileSystem);
            var nugettedDependencies = ReferenceNugetifierTester.AddReferenceMetadata(nugetifier, repositoriesConfig, new DirectoryInfo(projectRoot));

            Assert.That(nugettedDependencies, Is.Not.Empty);
            repositoriesConfig.Verify(r => r.RegisterRepository(It.Is <string>(path => path.StartsWith(projectRoot))));
        }
Ejemplo n.º 4
0
        public void TargetFrameworkAppearsInPackagesConfig(string targetFrameworkString)
        {
            FrameworkName targetFramework = targetFrameworkString != null?VersionUtility.ParseFrameworkName(targetFrameworkString) : null;

            var singleDependency            = ProjectReferenceTestData.ConstructMockDependency();
            var projectWithSingleDependency = ProjectReferenceTestData.ConstructMockProject(new[] { singleDependency.Object });
            var packageRepositoryWithCorrespondingPackage = ProjectReferenceTestData.CreateMockRepository();
            var projectFileSystem = new MockFileSystem();
            var nugetifier        = ReferenceNugetifierTester.BuildNugetifier(vsProject: projectWithSingleDependency, packageRepository: packageRepositoryWithCorrespondingPackage, projectFileSystem: projectFileSystem);

            ReferenceNugetifierTester.AddReferenceMetadata(nugetifier, targetFrameWork: targetFramework);

            var packageConfigs    = projectFileSystem.Paths.Select(pathAndData => new PackageReferenceFile(projectFileSystem, pathAndData.Key));
            var packageReferences = packageConfigs.SelectMany(config => config.GetPackageReferences()).ToList();

            Assert.That(packageReferences, Is.Not.Empty);
            Assert.That(packageReferences, Has.All.Matches <PackageReference>(x => Equals(targetFramework, x.TargetFramework)));
        }