本文整理汇总了C#中VsPackageManager.FindLocalPackage方法的典型用法代码示例。如果您正苦于以下问题:C# VsPackageManager.FindLocalPackage方法的具体用法?C# VsPackageManager.FindLocalPackage怎么用?C# VsPackageManager.FindLocalPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VsPackageManager
的用法示例。
在下文中一共展示了VsPackageManager.FindLocalPackage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindLocalPackageThrowsWhenOnlyUnusedVersionOfPackageIsPresentInPackagesFolder
public void FindLocalPackageThrowsWhenOnlyUnusedVersionOfPackageIsPresentInPackagesFolder()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var projectManager = new ProjectManager(sourceRepository, pathResolver, projectSystem, localRepository.Object);
var project = TestUtils.GetProject("foo");
var projects = new Project[] { project };
var packageA10 = PackageUtility.CreatePackage("A", "1.0", new string[] { "hello.txt" });
var packageA20 = PackageUtility.CreatePackage("A", "2.0", new string[] { "hello.txt" });
var packageA30 = PackageUtility.CreatePackage("A", "3.0", new string[] { "hello.txt" });
localRepository.Object.AddPackage(packageA10);
localRepository.Object.AddPackage(packageA20);
sourceRepository.AddPackage(packageA10);
sourceRepository.AddPackage(packageA20);
sourceRepository.AddPackage(packageA30);
var packageManager = new VsPackageManager(
TestUtils.GetSolutionManager(true, "foo", projects),
sourceRepository,
new Mock<IFileSystemProvider>().Object,
projectSystem,
localRepository.Object,
new Mock<IDeleteOnRestartManager>().Object,
new Mock<VsPackageInstallerEvents>().Object);
bool appliesToProject;
ExceptionAssert.Throws<PackageNotInstalledException>(() => packageManager.FindLocalPackage("A", out appliesToProject),
String.Format(CultureInfo.CurrentCulture, VsResources.PackageNotInstalledInAnyProject, "A"));
}
示例2: FindLocalPackageWhenAnUnusedVersionOfPackageIsPresentInPackagesFolder
public void FindLocalPackageWhenAnUnusedVersionOfPackageIsPresentInPackagesFolder()
{
// Arrange
var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
localRepository.Setup(m => m.IsReferenced("A", new SemanticVersion("2.0"))).Returns(true);
var sourceRepository = new MockPackageRepository();
var projectSystem = new MockProjectSystem();
var pathResolver = new DefaultPackagePathResolver(projectSystem);
var projectManager = new ProjectManager(sourceRepository, pathResolver, projectSystem, localRepository.Object);
var project = TestUtils.GetProject("foo");
var projects = new Project[] { project };
var packageA10 = PackageUtility.CreatePackage("A", "1.0", new string[] { "hello.txt" });
var packageA20 = PackageUtility.CreatePackage("A", "2.0", new string[] { "hello.txt" });
var packageA30 = PackageUtility.CreatePackage("A", "3.0", new string[] { "hello.txt" });
localRepository.Object.AddPackage(packageA10);
sourceRepository.AddPackage(packageA10);
sourceRepository.AddPackage(packageA20);
sourceRepository.AddPackage(packageA30);
var packageManager = new VsPackageManager(
TestUtils.GetSolutionManager(true, "foo", projects),
sourceRepository,
new Mock<IFileSystemProvider>().Object,
projectSystem,
localRepository.Object,
new Mock<IDeleteOnRestartManager>().Object,
new Mock<VsPackageInstallerEvents>().Object);
packageManager.InstallPackage(projectManager, "A", packageA20.Version, true, true, null);
bool appliesToProject;
IPackage package = packageManager.FindLocalPackage("A", out appliesToProject);
Assert.True(package.Version.Version.Major == 2);
Assert.True(appliesToProject);
}