本文整理汇总了C#中VsPackageManager.UpdatePackages方法的典型用法代码示例。如果您正苦于以下问题:C# VsPackageManager.UpdatePackages方法的具体用法?C# VsPackageManager.UpdatePackages怎么用?C# VsPackageManager.UpdatePackages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VsPackageManager
的用法示例。
在下文中一共展示了VsPackageManager.UpdatePackages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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")));
}
示例2: UpdatePackagesEndToEndWhereNewerVersionPackageDoesNotHaveDependencyLikeOlderVersion
public void UpdatePackagesEndToEndWhereNewerVersionPackageDoesNotHaveDependencyLikeOlderVersion()
{
// 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" }, dependencies: new[] { PackageDependency.CreateDependency("B", "1.0") });
var A2 = PackageUtility.CreatePackage("A", "2.0", new[] { "hello2" }, dependencies: new[] { PackageDependency.CreateDependency("C", "1.0") });
var B1 = PackageUtility.CreatePackage("B", "1.0", new[] { "world1" });
var B2 = PackageUtility.CreatePackage("B", "2.0", new[] { "world2" });
var C1 = PackageUtility.CreatePackage("C", "1.0", new[] { "galaxy1" });
var C2 = PackageUtility.CreatePackage("C", "2.0", new[] { "galaxy2" });
sourceRepository.AddPackage(A1);
sourceRepository.AddPackage(A2);
sourceRepository.AddPackage(B1);
sourceRepository.AddPackage(B2);
sourceRepository.AddPackage(C1);
sourceRepository.AddPackage(C2);
localRepository.AddPackage(A1);
localRepository.AddPackage(B1);
localRepository.AddPackage(C1);
projectRepository.Add(A1);
projectRepository.Add(B1);
projectRepository.Add(C1);
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 installWalker = new InstallWalker(
localRepository,
sourceRepository,
null,
logger: NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: true);
IList<IPackage> updatePackagesByDependencyOrder;
var updatePackages = new List<IPackage> { A2, B2, C2 };
var operationsForShowingLicense = installWalker.ResolveOperations(updatePackages, out updatePackagesByDependencyOrder);
// Act
packageManager.UpdatePackages(projectManager, updatePackagesByDependencyOrder, operationsForShowingLicense, updateDependencies: true, allowPrereleaseVersions: true, logger: NullLogger.Instance);
// Assert
// NOTE THAT BELOW, there is no uninstall operation for B1 but only for C1. Because A2 depends on C1 only where A1 depends on B1 only
// And, the operations are resolved for A2 NOT A1
Assert.True(operationsForShowingLicense.Count == 4);
Assert.True(operationsForShowingLicense[0].Package == A2 && operationsForShowingLicense[0].Action == PackageAction.Install);
Assert.True(operationsForShowingLicense[1].Package == B2 && operationsForShowingLicense[1].Action == PackageAction.Install);
Assert.True(operationsForShowingLicense[2].Package == C1 && operationsForShowingLicense[2].Action == PackageAction.Uninstall);
Assert.True(operationsForShowingLicense[3].Package == C2 && operationsForShowingLicense[3].Action == PackageAction.Install);
Assert.True(updatePackagesByDependencyOrder.Count == 3);
Assert.True(updatePackagesByDependencyOrder[0] == C2);
Assert.True(updatePackagesByDependencyOrder[1] == A2);
Assert.True(updatePackagesByDependencyOrder[2] == B2);
Assert.True(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(localRepository.Exists("C", new SemanticVersion("2.0")));
Assert.False(localRepository.Exists("C", new SemanticVersion("1.0")));
Assert.True(projectRepository.Exists("A", new SemanticVersion("2.0")));
Assert.True(projectRepository.Exists("B", new SemanticVersion("2.0")));
Assert.True(projectRepository.Exists("C", new SemanticVersion("2.0")));
}
示例3: UpdatePackageShowWarningIfThereIsOrphanedPackageUnderPackagesFolder
public void UpdatePackageShowWarningIfThereIsOrphanedPackageUnderPackagesFolder()
{
// 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 orphanPackage = PackageUtility.CreatePackage("orphan", "1.0", new [] { "content" });
localRepository.AddPackage(orphanPackage);
var logger = new Mock<ILogger>();
logger.Setup(l => l.Log(MessageLevel.Warning, "'orphan' was not installed in any project. Update failed.")).Verifiable();
// Act
packageManager.UpdatePackages(updateDependencies: true, allowPrereleaseVersions: true, logger: logger.Object, eventListener: new Mock<IPackageOperationEventListener>().Object);
// Assert
logger.Verify();
}
示例4: UpdatePackagesSetOperationToUpdate1
public void UpdatePackagesSetOperationToUpdate1()
{
// Arrange
var localRepository = new MockSharedPackageRepository();
var sourceRepository = new MockPackageRepository();
var projectRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var projectManager = new ProjectManager(localRepository, pathResolver, new MockProjectSystem(), projectRepository);
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("phuong", "1.0", new[] { "hello" });
localRepository.AddPackage(package);
projectRepository.AddPackage(package);
var package2 = PackageUtility.CreatePackage("phuong", "2.0", new[] { "hello" });
sourceRepository.AddPackage(package2);
// Act
packageManager.UpdatePackages(
projectManager,
updateDependencies: true,
allowPrereleaseVersions: true,
logger: NullLogger.Instance);
// Assert
Assert.Equal("Update", sourceRepository.LastOperation);
Assert.Equal("phuong", sourceRepository.LastMainPackageId);
Assert.Equal("2.0", sourceRepository.LastMainPackageVersion);
}