当前位置: 首页>>代码示例>>C#>>正文


C# VsPackageManager类代码示例

本文整理汇总了C#中VsPackageManager的典型用法代码示例。如果您正苦于以下问题:C# VsPackageManager类的具体用法?C# VsPackageManager怎么用?C# VsPackageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VsPackageManager类属于命名空间,在下文中一共展示了VsPackageManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InstallMetadataPackageWithReadMeInstallsIntoProjectAndPackageManager

        public void InstallMetadataPackageWithReadMeInstallsIntoProjectAndPackageManager()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            var packageA = PackageUtility.CreatePackage("A", "1.0", dependencies: new[] { new PackageDependency("B") });
            var mockPackageA = Mock.Get(packageA);
            mockPackageA.Setup(m => m.GetFiles()).Returns(PackageUtility.CreateFiles(new[] { "readme.txt" }));

            var packageB = PackageUtility.CreatePackage("B", "1.0", content: new[] { "hello.txt" });
            sourceRepository.AddPackage(packageA);
            sourceRepository.AddPackage(packageB);

            // Act
            packageManager.InstallPackage(projectManager, "A", new SemanticVersion("1.0"), ignoreDependencies: false, allowPrereleaseVersions: false, logger: NullLogger.Instance);

            // Assert
            Assert.True(packageManager.LocalRepository.Exists(packageA));
            Assert.True(projectManager.LocalRepository.Exists(packageA));

            Assert.True(packageManager.LocalRepository.Exists(packageB));
            Assert.True(projectManager.LocalRepository.Exists(packageB));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:28,代码来源:VsPackageManagerTest.cs

示例2: InstallPackageSetOperationToInstall3

        public void InstallPackageSetOperationToInstall3()
        {
            // Arrange
            var localRepository = new MockSharedPackageRepository();
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });
            sourceRepository.AddPackage(package);

            var package2 = PackageUtility.CreatePackage("bar", "2.0", new[] { "world" });
            sourceRepository.AddPackage(package2);

            // Act
            packageManager.InstallPackage(
                projectManager,
                package2,
                new PackageOperation[] { 
                    new PackageOperation(package, PackageAction.Install),
                    new PackageOperation(package2, PackageAction.Install),
                },
                ignoreDependencies: false, 
                allowPrereleaseVersions: false, 
                logger: NullLogger.Instance);

            // Assert
            Assert.Equal("Install", sourceRepository.LastOperation);
            Assert.Equal("bar", sourceRepository.LastMainPackageId);
            Assert.Equal("2.0", sourceRepository.LastMainPackageVersion);
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:33,代码来源:VsPackageManagerTest.Operation.cs

示例3: ReinstallPackagesRestoresPackageWithTheSameVersion

        public void ReinstallPackagesRestoresPackageWithTheSameVersion()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, projectSystem, new MockPackageRepository());

            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository,
                new Mock<IDeleteOnRestartManager>().Object,
                new Mock<VsPackageInstallerEvents>().Object);

            var packageA = PackageUtility.CreatePackage("A", "1.2", new[] { "content.txt" });
            sourceRepository.Add(packageA);
            localRepository.AddPackage(packageA);
            projectManager.LocalRepository.AddPackage(packageA);

            // Act
            packageManager.ReinstallPackage(projectManager, "A", updateDependencies: true, allowPrereleaseVersions: true, logger: null);

            // Assert
            Assert.True(packageManager.LocalRepository.Exists("A", new SemanticVersion("1.2")));
            Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("1.2")));
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:30,代码来源:VsPackageManagerTest.Reinstall.cs

示例4: InstallPackageUsesProjectTargetFramework

        public void InstallPackageUsesProjectTargetFramework()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem(new FrameworkName(".NETFramework, Version=4.5"));
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, projectSystem, new MockPackageRepository());
            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(), 
                sourceRepository, 
                new Mock<IFileSystemProvider>().Object, 
                projectSystem, 
                localRepository, 
                new Mock<IRecentPackageRepository>().Object, 
                new Mock<VsPackageInstallerEvents>().Object);

            var dependencySets = new PackageDependencySet[] {
                new PackageDependencySet(
                    new FrameworkName(".NETFramework, Version=4.5"),
                    new [] { new PackageDependency("B") }),

                new PackageDependencySet(
                    new FrameworkName(".NETFramework, Version=4.0"),
                    new [] { new PackageDependency("C") })
            };

            var package = PackageUtility.CreatePackageWithDependencySets(
                "foo", 
                "1.0", 
                new[] { "hello" },
                dependencySets: dependencySets);

            var packageB = PackageUtility.CreatePackage("B", "2.0", new[] { "good morning" });
            var packageC = PackageUtility.CreatePackage("C", "2.0", new[] { "good morning" });
            sourceRepository.AddPackage(package);
            sourceRepository.AddPackage(packageB);
            sourceRepository.AddPackage(packageC);

            // Act
            packageManager.InstallPackage(projectManager, "foo", new SemanticVersion("1.0"), ignoreDependencies: false, allowPrereleaseVersions: false, logger: NullLogger.Instance);

            // Assert
            Assert.True(packageManager.LocalRepository.Exists(package));
            Assert.True(packageManager.LocalRepository.Exists(packageB));
            Assert.False(packageManager.LocalRepository.Exists(packageC));
            Assert.True(projectManager.LocalRepository.Exists(package));
            Assert.True(projectManager.LocalRepository.Exists(packageB));
        }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:49,代码来源:VsPackageManagerTest.cs

示例5: ReinstallPackagesSkipsReinstallingIfPackageDoesNotExistAndLogWarning

        public void ReinstallPackagesSkipsReinstallingIfPackageDoesNotExistAndLogWarning()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, projectSystem, new MockPackageRepository());

            var installerEvents = new Mock<VsPackageInstallerEvents>(MockBehavior.Strict);
            int eventCount = 0;
            RegisterInstallerEvents(installerEvents, _ => eventCount++);

            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository,
                new Mock<IDeleteOnRestartManager>().Object,
                installerEvents.Object);

            var packageA = PackageUtility.CreatePackage("A", "1.2", new[] { "content.txt" });
            sourceRepository.Add(packageA);
            localRepository.AddPackage(packageA);
            projectManager.LocalRepository.AddPackage(packageA);

            // remove package from source repository to simulate missing package condition
            sourceRepository.Remove(packageA);

            var logger = new Mock<ILogger>();
            logger.Setup(s => s.Log(
                MessageLevel.Warning, 
                "Skipped reinstalling package '{0}' in project '{1}' because the package does not exist in the package source.", 
                "A 1.2",
                "x:\\MockFileSystem")
            ).Verifiable();

            // Act
            packageManager.ReinstallPackage(projectManager, "A", updateDependencies: true, allowPrereleaseVersions: true, logger: logger.Object);

            // Assert
            logger.Verify();
            Assert.Equal(0, eventCount);

            Assert.True(packageManager.LocalRepository.Exists("A", new SemanticVersion("1.2")));
            Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("1.2")));
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:48,代码来源:VsPackageManagerTest.Reinstall.cs

示例6: InstallPackageInstallsIntoProjectAndPackageManager

        public void InstallPackageInstallsIntoProjectAndPackageManager()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });
            sourceRepository.AddPackage(package);

            // Act
            packageManager.InstallPackage(projectManager, "foo", new SemanticVersion("1.0"), ignoreDependencies: false, allowPrereleaseVersions: false, logger: NullLogger.Instance);

            // Assert
            Assert.True(packageManager.LocalRepository.Exists(package));
            Assert.True(projectManager.LocalRepository.Exists(package));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:20,代码来源:VsPackageManagerTest.cs

示例7: UpdatePackagesWithOperationsAddPackageCorrectly

        public void UpdatePackagesWithOperationsAddPackageCorrectly()
        {
            // Arrange            
            var localRepository = new MockSharedPackageRepository();

            var projectRepository = new MockProjectPackageRepository(localRepository);
            var sourceRepository = new MockPackageRepository();
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            var A1 = PackageUtility.CreatePackage("A", "1.0", new[] { "hello1" });
            var A2 = PackageUtility.CreatePackage("A", "2.0", new[] { "hello2" });
            var A3 = PackageUtility.CreatePackage("A", "3.0", new[] { "hello3" });

            var B1 = PackageUtility.CreatePackage("B", "1.0", new[] { "world1" });
            var B2 = PackageUtility.CreatePackage("B", "2.0", new[] { "world2" });

            sourceRepository.AddPackage(A2);
            sourceRepository.AddPackage(A3);
            sourceRepository.AddPackage(B1);
            sourceRepository.AddPackage(B2);

            localRepository.AddPackage(A1);
            localRepository.AddPackage(B1);

            projectRepository.Add(A1);
            projectRepository.Add(B1);

            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, fileSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);
            var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), projectRepository);
 
            var operations = new PackageOperation[] {
                new PackageOperation(A3, PackageAction.Install),
                new PackageOperation(B2, PackageAction.Install)
            };

            // Act
            packageManager.UpdatePackages(projectManager, new[] { A3, B2 }, operations, updateDependencies: true, allowPrereleaseVersions: true, logger: NullLogger.Instance);

            // Assert
            Assert.True(localRepository.Exists("A", new SemanticVersion("3.0")));
            Assert.False(localRepository.Exists("A", new SemanticVersion("2.0")));
            Assert.False(localRepository.Exists("A", new SemanticVersion("1.0")));

            Assert.True(localRepository.Exists("B", new SemanticVersion("2.0")));
            Assert.False(localRepository.Exists("B", new SemanticVersion("1.0")));

            Assert.True(projectRepository.Exists("A", new SemanticVersion("3.0")));
            Assert.True(projectRepository.Exists("B", new SemanticVersion("2.0")));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:49,代码来源:VsPackageManagerTest.cs

示例8: UpdatePackageUpdatesToTheHighestPackageIfPrereleaseFlagIsSetToTrue

        public void UpdatePackageUpdatesToTheHighestPackageIfPrereleaseFlagIsSetToTrue()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            var package3_10A = PackageUtility.CreatePackage("qux", "1.0-alpha");
            var package3_11B = PackageUtility.CreatePackage("qux", "1.1-alpha");
            var package3_10 = PackageUtility.CreatePackage("qux", "1.0");
            var package3_09 = PackageUtility.CreatePackage("qux", "0.9");
            localRepository.AddPackage(package3_10);
            localRepository.AddPackage(package3_10A);
            localRepository.AddPackage(package3_11B);
            localRepository.AddPackage(package3_09);

            // Act
            packageManager.InstallPackage(package3_09, ignoreDependencies: false, allowPrereleaseVersions: true);
            Assert.True(packageManager.LocalRepository.Exists(package3_09));
            packageManager.UpdatePackage("qux", updateDependencies: true, allowPrereleaseVersions: true);

            // Assert
            Assert.True(packageManager.LocalRepository.Exists(package3_11B));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:26,代码来源:VsPackageManagerTest.cs

示例9: ReinstallPackagesRestoresAllPackagesInAProjectWithNewContentIfProjectFrameworkChanges

        public void ReinstallPackagesRestoresAllPackagesInAProjectWithNewContentIfProjectFrameworkChanges()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem(new FrameworkName(".NETFramework, Version=v3.0"));
            var pathResolver = new DefaultPackagePathResolver(projectSystem);

            var packageReferenceRepository = new PackageReferenceRepository(projectSystem, localRepository);
            var projectManager = new ProjectManager(localRepository, pathResolver, projectSystem, packageReferenceRepository);

            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository,
                new Mock<IDeleteOnRestartManager>().Object,
                new Mock<VsPackageInstallerEvents>().Object);

            var packageA = PackageUtility.CreatePackage(
                "A",
                "1.2-alpha",
                new[] { "net30\\content.txt", "silverlight40\\content4.txt" },
                new[] { "lib\\net30\\ref.dll", "lib\\silverlight40\\refsl.dll" });

            var packageB = PackageUtility.CreatePackage(
                "B",
                "2.0",
                new[] { "net30\\contentB.txt", "silverlight40\\content4B.txt" },
                new[] { "lib\\net30\\refB.dll", "lib\\silverlight40\\refslB.dll" });

            sourceRepository.Add(packageA);
            sourceRepository.Add(packageB);

            packageManager.InstallPackage(projectManager, "A", new SemanticVersion("1.2-alpha"), ignoreDependencies: false, allowPrereleaseVersions: true, logger: null);
            packageManager.InstallPackage(projectManager, "B", new SemanticVersion("2.0"), ignoreDependencies: false, allowPrereleaseVersions: true, logger: null);

            Assert.True(packageManager.LocalRepository.Exists("A", new SemanticVersion("1.2-alpha")));
            Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("1.2-alpha")));
            Assert.True(projectSystem.FileExists("content.txt"));
            Assert.False(projectSystem.FileExists("content4.txt"));
            Assert.True(projectSystem.ReferenceExists("ref.dll"));
            Assert.False(projectSystem.ReferenceExists("refsl.dll"));

            Assert.True(packageManager.LocalRepository.Exists("B"));
            Assert.True(projectManager.LocalRepository.Exists("B"));
            Assert.True(projectSystem.FileExists("contentB.txt"));
            Assert.False(projectSystem.FileExists("content4B.txt"));
            Assert.True(projectSystem.ReferenceExists("refB.dll"));
            Assert.False(projectSystem.ReferenceExists("refslB.dll"));

            // now change project's target framework to silverlight
            projectSystem.ChangeTargetFramework(new FrameworkName("Silverlight, Version=v4.0"));

            // Act
            packageManager.ReinstallPackages(projectManager, updateDependencies: true, allowPrereleaseVersions: false, logger: null);

            // Assert
            Assert.True(packageManager.LocalRepository.Exists("A", new SemanticVersion("1.2-alpha")));
            Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("1.2-alpha")));
            Assert.False(projectSystem.FileExists("content.txt"));
            Assert.True(projectSystem.FileExists("content4.txt"));
            Assert.False(projectSystem.ReferenceExists("ref.dll"));
            Assert.True(projectSystem.ReferenceExists("refsl.dll"));

            Assert.True(packageManager.LocalRepository.Exists("B"));
            Assert.True(projectManager.LocalRepository.Exists("B"));
            Assert.False(projectSystem.FileExists("contentB.txt"));
            Assert.True(projectSystem.FileExists("content4B.txt"));
            Assert.False(projectSystem.ReferenceExists("refB.dll"));
            Assert.True(projectSystem.ReferenceExists("refslB.dll"));
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:73,代码来源:VsPackageManagerTest.Reinstall.cs

示例10: InstallPackageThrowsIfMinClientVersionIsNotSatisfied

        public void InstallPackageThrowsIfMinClientVersionIsNotSatisfied()
        {
            // Arrange
            Version nugetVersion = typeof(IPackage).Assembly.GetName().Version;
            Version requiredVersion = new Version(nugetVersion.Major, nugetVersion.Minor, nugetVersion.Build, nugetVersion.Revision + 1);

            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" }, minClientVersion: requiredVersion.ToString());
            sourceRepository.AddPackage(package);

            string expectedErrorMessage =
                String.Format("The '{0}' package requires NuGet client version '{1}' or above, but the current NuGet version is '{2}'.", "foo 1.0", requiredVersion.ToString(), nugetVersion.ToString());

            // Act & Assert
            ExceptionAssert.Throws<NuGetVersionNotSatisfiedException>(
                () => packageManager.InstallPackage(projectManager, "foo", new SemanticVersion("1.0"), ignoreDependencies: false, allowPrereleaseVersions: false, logger: NullLogger.Instance),
                expectedErrorMessage);
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:24,代码来源:VsPackageManagerTest.cs

示例11: UpdatePackageWithNoProjectsInstallsAtSolutionLevel

        public void UpdatePackageWithNoProjectsInstallsAtSolutionLevel()
        {
            // Arrange 
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            var package = PackageUtility.CreatePackage("foo", "1.0", dependencies: new PackageDependency[] { new PackageDependency("bar") });
            sourceRepository.AddPackage(package);

            var package2 = PackageUtility.CreatePackage("bar", "2.0");
            sourceRepository.AddPackage(package2);

            var package3 = PackageUtility.CreatePackage("awesome", "1.0");
            localRepository.AddPackage(package3);

            var operations = new PackageOperation[] {  
                 new PackageOperation(package, PackageAction.Install), 
                 new PackageOperation(package2, PackageAction.Install), 
                 new PackageOperation(package3, PackageAction.Uninstall) 
             };

            // Act 
            packageManager.UpdatePackage(Enumerable.Empty<Project>(),
                                         package,
                                         operations,
                                         updateDependencies: true,
                                         allowPrereleaseVersions: false,
                                         logger: NullLogger.Instance,
                                         packageOperationEventListener: null);

            // Assert 
            Assert.True(packageManager.LocalRepository.Exists(package));
            Assert.True(packageManager.LocalRepository.Exists(package2));
            Assert.True(!packageManager.LocalRepository.Exists(package3));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:38,代码来源:VsPackageManagerTest.cs

示例12: InstallPackageDoesNotCallsMarkPackageDirectoryForDeletion

        public void InstallPackageDoesNotCallsMarkPackageDirectoryForDeletion()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
            var sourceRepository = new MockPackageRepository();
            var packageA = PackageUtility.CreatePackage("A");
            var deleteOnRestartManager = new Mock<IDeleteOnRestartManager>(MockBehavior.Strict);
            sourceRepository.AddPackage(packageA);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, new MockFileSystem(), localRepository.Object,
                deleteOnRestartManager.Object, new Mock<VsPackageInstallerEvents>().Object);

            // Act
            packageManager.InstallPackage(null, "A", new SemanticVersion("1.0"), ignoreDependencies: false, allowPrereleaseVersions: false, logger: NullLogger.Instance);

            // Assert
            deleteOnRestartManager.Verify();
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:17,代码来源:VsPackageManagerTest.cs

示例13: InstallPackageWithOperationsInstallsMetaPackageSuccessfully

        public void InstallPackageWithOperationsInstallsMetaPackageSuccessfully()
        {
            // Arrange 
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>().Object;
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), new MockPackageRepository());
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, projectSystem, localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            var package = PackageUtility.CreatePackage("foo", "1.0", dependencies: new [] { new PackageDependency("bar") });
            sourceRepository.AddPackage(package);

            var package2 = PackageUtility.CreatePackage("bar", "2.0", content: new[] { "world" });
            sourceRepository.AddPackage(package2);

            var operations = new PackageOperation[] {  
                 new PackageOperation(package, PackageAction.Install), 
                 new PackageOperation(package2, PackageAction.Install), 
             };

            // Act 
            packageManager.InstallPackage(projectManager, package, operations, ignoreDependencies: false, allowPrereleaseVersions: false, logger: NullLogger.Instance);

            // Assert 
            Assert.True(packageManager.LocalRepository.Exists(package));
            Assert.True(packageManager.LocalRepository.Exists(package2));

            Assert.True(projectManager.LocalRepository.Exists(package));
            Assert.True(projectManager.LocalRepository.Exists(package2));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:31,代码来源:VsPackageManagerTest.cs

示例14: InstallSolutionLevelPackageAddEntryToSolutionPackagesConfig2

        public void InstallSolutionLevelPackageAddEntryToSolutionPackagesConfig2(bool skipAssemblyReferences)
        {
            // Arrange
            // Source repository has A -> B, where B is a project-level package and A is a meta-package.
            // We want to make sure A is added to the packages.config of the project, and NOT packages.config of the solution
            var localRepository = new MockSharedPackageRepository();

            var sourceRepository = new MockPackageRepository();
            var packageA = PackageUtility.CreatePackage("A", "2.0", tools: new[] { "install.ps1" });
            sourceRepository.Add(packageA);

            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);

            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository,
                new Mock<IDeleteOnRestartManager>().Object,
                new Mock<VsPackageInstallerEvents>().Object);

            var projectRepository = new MockProjectPackageRepository(localRepository);
            var projectManager = new ProjectManager(localRepository, pathResolver, projectSystem, projectRepository);

            // Act
            packageManager.InstallPackage(
                projectManager,
                "A",
                new SemanticVersion("2.0"),
                ignoreDependencies: false,
                allowPrereleaseVersions: true,
                skipAssemblyReferences: skipAssemblyReferences,
                logger: null);

            // Assert
            Assert.True(!projectRepository.Exists("A", new SemanticVersion("2.0")));

            // assert that packages.config for solution-level is created.
            Assert.True(localRepository.IsSolutionReferenced("A", new SemanticVersion("2.0")));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:42,代码来源:VsPackageManagerTest.cs

示例15: InstallMetaPackageDoesNotAddEntryToSolutionPackagesConfig2

        public void InstallMetaPackageDoesNotAddEntryToSolutionPackagesConfig2(bool skipAssemblyReferences)
        {
            // Arrange
            // Source repository has A -> B, where B is a project-level package and A is a meta-package.
            // We want to make sure A is added to the packages.config of the project, and NOT packages.config of the solution
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();

            var sourceRepository = new MockPackageRepository();
            var packageB = PackageUtility.CreatePackage("B", "1.0", new string[] { "hello.txt" });
            var packageA = PackageUtility.CreatePackage("A", "2.0", new string[] { "world" }, dependencies: new[] { new PackageDependency("B") });
            sourceRepository.Add(packageA);
            sourceRepository.Add(packageB);

            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);

            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository.Object,
                new Mock<IDeleteOnRestartManager>().Object,
                new Mock<VsPackageInstallerEvents>().Object);

            var projectRepository = new MockProjectPackageRepository(localRepository.Object);
            var projectManager = new ProjectManager(localRepository.Object, pathResolver, projectSystem, projectRepository);

            localRepository.Setup(r => r.IsReferenced(It.IsAny<string>(), It.IsAny<SemanticVersion>())).
                Returns((string id, SemanticVersion version) => projectRepository.Exists(id, version));

            // Act
            packageManager.InstallPackage(
                projectManager, 
                "A", 
                new SemanticVersion("2.0"), 
                ignoreDependencies: false, 
                allowPrereleaseVersions: true, 
                skipAssemblyReferences: skipAssemblyReferences, 
                logger: null);

            // Assert
            Assert.True(projectRepository.Exists("A", new SemanticVersion("2.0")));
            Assert.True(projectRepository.Exists("B", new SemanticVersion("1.0")));

            // assert that packages.config for solution-level is not created.
            Assert.False(localRepository.Object.IsSolutionReferenced("A", new SemanticVersion("2.0")));
            Assert.False(localRepository.Object.IsSolutionReferenced("B", new SemanticVersion("1.0")));
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:49,代码来源:VsPackageManagerTest.cs


注:本文中的VsPackageManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。