本文整理汇总了C#中InstallWalker类的典型用法代码示例。如果您正苦于以下问题:C# InstallWalker类的具体用法?C# InstallWalker怎么用?C# InstallWalker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstallWalker类属于命名空间,在下文中一共展示了InstallWalker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ResolveDependenciesForInstallPackageResolvesDependencyUsingDependencyProvider
public void ResolveDependenciesForInstallPackageResolvesDependencyUsingDependencyProvider()
{
// Arrange
IPackage packageA = PackageUtility.CreatePackage("A",
"1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
});
IPackage packageB = PackageUtility.CreatePackage("B");
var repository = new Mock<PackageRepositoryBase>();
repository.Setup(c => c.GetPackages()).Returns(new[] { packageA }.AsQueryable());
var dependencyProvider = repository.As<IDependencyResolver>();
dependencyProvider.Setup(c => c.ResolveDependency(It.Is<PackageDependency>(p => p.Id == "B"), It.IsAny<IPackageConstraintProvider>(), false, true, DependencyVersion.Lowest))
.Returns(packageB).Verifiable();
var localRepository = new MockPackageRepository();
IPackageOperationResolver resolver = new InstallWalker(localRepository,
repository.Object,
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act
var operations = resolver.ResolveOperations(packageA).ToList();
// Assert
Assert.Equal(2, operations.Count);
Assert.Equal(PackageAction.Install, operations.First().Action);
Assert.Equal(packageB, operations.First().Package);
Assert.Equal(PackageAction.Install, operations.Last().Action);
Assert.Equal(packageA, operations.Last().Package);
dependencyProvider.Verify();
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:35,代码来源:PackageWalkerTest.cs
示例2: ResolveDependenciesForInstallPackageWithUnknownDependencyThrows
public void ResolveDependenciesForInstallPackageWithUnknownDependencyThrows()
{
// Arrange
IPackage package = PackageUtility.CreatePackage("A",
"1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
});
IPackageOperationResolver resolver = new InstallWalker(new MockPackageRepository(),
new MockPackageRepository(),
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act & Assert
ExceptionAssert.Throws<InvalidOperationException>(() => resolver.ResolveOperations(package), "Unable to resolve dependency 'B'.");
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:18,代码来源:PackageWalkerTest.cs
示例3: InstallWalkerResolvesLowestMajorAndMinorHighestPatchVersionOfListedPackagesForDependencies
public void InstallWalkerResolvesLowestMajorAndMinorHighestPatchVersionOfListedPackagesForDependencies()
{
// Arrange
// A 1.0 -> B 1.0
// B 1.0 -> C 1.1
// C 1.1 -> D 1.0
var A10 = PackageUtility.CreatePackage("A", "1.0", dependencies: new[] { PackageDependency.CreateDependency("B", "1.0") });
var repository = new MockPackageRepository() {
PackageUtility.CreatePackage("B", "2.0", dependencies: new[] { PackageDependency.CreateDependency("C", "1.1") }),
PackageUtility.CreatePackage("B", "1.0", dependencies: new[] { PackageDependency.CreateDependency("C", "1.1") }, listed: false),
PackageUtility.CreatePackage("B", "1.0.1"),
A10,
PackageUtility.CreatePackage("D", "2.0"),
PackageUtility.CreatePackage("C", "1.1.3", dependencies: new[] { PackageDependency.CreateDependency("D", "1.0") }),
PackageUtility.CreatePackage("C", "1.1.1", dependencies: new[] { PackageDependency.CreateDependency("D", "1.0") }, listed: false),
PackageUtility.CreatePackage("C", "1.5.1", dependencies: new[] { PackageDependency.CreateDependency("D", "1.0") }),
PackageUtility.CreatePackage("B", "1.0.9", dependencies: new[] { PackageDependency.CreateDependency("C", "1.1") }),
PackageUtility.CreatePackage("B", "1.1", dependencies: new[] { PackageDependency.CreateDependency("C", "1.1") })
};
IPackageOperationResolver resolver = new InstallWalker(new MockPackageRepository(),
repository,
constraintProvider: null,
logger: NullLogger.Instance,
targetFramework: null,
ignoreDependencies: false,
allowPrereleaseVersions: false)
{
DependencyVersion = DependencyVersion.HighestPatch
};
// Act
var packages = resolver.ResolveOperations(A10).ToList();
// Assert
Assert.Equal(4, packages.Count);
Assert.Equal("D", packages[0].Package.Id);
Assert.Equal(new SemanticVersion("2.0"), packages[0].Package.Version);
Assert.Equal("C", packages[1].Package.Id);
Assert.Equal(new SemanticVersion("1.1.3"), packages[1].Package.Version);
Assert.Equal("B", packages[2].Package.Id);
Assert.Equal(new SemanticVersion("1.0.9"), packages[2].Package.Version);
Assert.Equal("A", packages[3].Package.Id);
Assert.Equal(new SemanticVersion("1.0"), packages[3].Package.Version);
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:49,代码来源:PackageWalkerTest.cs
示例4: ResolveOperationsForPackagesWherePackagesOrderIsDifferentFromItsDependencyOrder
public void ResolveOperationsForPackagesWherePackagesOrderIsDifferentFromItsDependencyOrder()
{
// Arrange
// A 1.0 -> B 1.0 to 1.5
// A 2.0 -> B 1.8
// B 1.0
// B 2.0
// C 1.0
// C 2.0
var A10 = PackageUtility.CreatePackage("A", "1.0", dependencies: new[] { PackageDependency.CreateDependency("B", "[1.0, 1.5]") });
var A20 = PackageUtility.CreatePackage("A", "2.0", dependencies: new[] { PackageDependency.CreateDependency("B", "1.8") });
var B10 = PackageUtility.CreatePackage("B", "1.0");
var B20 = PackageUtility.CreatePackage("B", "2.0");
var C10 = PackageUtility.CreatePackage("C", "1.0");
var C20 = PackageUtility.CreatePackage("C", "2.0");
var sourceRepository = new MockPackageRepository() {
A10,
A20,
B10,
B20,
C10,
C20,
};
var localRepository = new MockPackageRepository() {
A10,
B10,
C10
};
var resolver = new InstallWalker(localRepository,
sourceRepository,
constraintProvider: NullConstraintProvider.Instance,
logger: NullLogger.Instance,
targetFramework: null,
ignoreDependencies: false,
allowPrereleaseVersions: false);
var updatePackages = new List<IPackage> { A20, B20, C20 };
IList<IPackage> allUpdatePackagesByDependencyOrder;
// Act
var operations = resolver.ResolveOperations(updatePackages, out allUpdatePackagesByDependencyOrder);
// Assert
Assert.True(operations.Count == 3);
Assert.True(operations[0].Package == B20 && operations[0].Action == PackageAction.Install);
Assert.True(operations[1].Package == A20 && operations[1].Action == PackageAction.Install);
Assert.True(operations[2].Package == C20 && operations[2].Action == PackageAction.Install);
Assert.True(allUpdatePackagesByDependencyOrder[0] == B20);
Assert.True(allUpdatePackagesByDependencyOrder[1] == A20);
Assert.True(allUpdatePackagesByDependencyOrder[2] == C20);
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:57,代码来源:PackageWalkerTest.cs
示例5: ResolveDependenciesForInstallPackageResolvesDependencyWithConstraintsUsingDependencyResolver
public void ResolveDependenciesForInstallPackageResolvesDependencyWithConstraintsUsingDependencyResolver()
{
// Arrange
var packageDependency = new PackageDependency("B", new VersionSpec { MinVersion = new SemanticVersion("1.1") });
IPackage packageA = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> { packageDependency });
IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0");
IPackage packageB12 = PackageUtility.CreatePackage("B", "1.2");
var repository = new Mock<PackageRepositoryBase>(MockBehavior.Strict);
repository.Setup(c => c.GetPackages()).Returns(new[] { packageA }.AsQueryable());
var dependencyProvider = repository.As<IDependencyResolver>();
dependencyProvider.Setup(c => c.ResolveDependency(packageDependency, It.IsAny<IPackageConstraintProvider>(), false, true))
.Returns(packageB12).Verifiable();
var localRepository = new MockPackageRepository();
IPackageOperationResolver resolver = new InstallWalker(localRepository,
repository.Object,
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act
var operations = resolver.ResolveOperations(packageA).ToList();
// Assert
Assert.Equal(2, operations.Count);
Assert.Equal(PackageAction.Install, operations.First().Action);
Assert.Equal(packageB12, operations.First().Package);
Assert.Equal(PackageAction.Install, operations.Last().Action);
Assert.Equal(packageA, operations.Last().Package);
dependencyProvider.Verify();
}
开发者ID:monoman,项目名称:NugetCracker,代码行数:34,代码来源:PackageWalkerTest.cs
示例6: ShowLicenseAgreementForAllPackages
protected bool ShowLicenseAgreementForAllPackages(IVsPackageManager activePackageManager, out IList<PackageOperation> allOperations, out IList<IPackage> packagesByDependencyOrder)
{
allOperations = new List<PackageOperation>();
var allPackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease);
if (_project.SupportsINuGetProjectSystem())
{
packagesByDependencyOrder = allPackages.ToList();
foreach (var package in allPackages)
{
allOperations.Add(new PackageOperation(package, PackageAction.Install));
}
}
else
{
var installWalker = new InstallWalker(
LocalRepository,
activePackageManager.SourceRepository,
_project.GetTargetFrameworkName(),
logger: this,
ignoreDependencies: false,
allowPrereleaseVersions: IncludePrerelease,
dependencyVersion: activePackageManager.DependencyVersion);
allOperations = installWalker.ResolveOperations(allPackages, out packagesByDependencyOrder);
}
return ShowLicenseAgreement(activePackageManager, allOperations);
}
开发者ID:Mailaender,项目名称:xamarin-nuget,代码行数:27,代码来源:UpdatesProvider.cs
示例7: ReinstallPackages
// Reinstall all packages in all projects
public void ReinstallPackages(
bool updateDependencies,
bool allowPrereleaseVersions,
ILogger logger,
IPackageOperationEventListener eventListener)
{
//1) Reinstall solution packages first
//2) On Each Project, call UninstallAllPackages(IProjectManager, Dictionary<Tuple<string, SemanticVersion>, bool>, out packagesInSourceRepository). And, create a dictionary <projectManager, packages>
//3) Append all packagesInSourceRepository into allPackagesInSourceRepository
//4) Call InstallWalker.ResolveOperations(allPackagesInSourceRepository, out IList<IPackage> packagesByDependencyOrder)
//5) Call for each entry in Dictionary<projectManager, packages>
// InitializeLogger, RunSolutionAction( call projectManager.AddPackageReference(IPackage, ..., ...)
// Change it to array so that the enumeration is not modified during enumeration to reinstall solution packages
var packages = LocalRepository.GetPackages().ToArray();
foreach (var package in packages)
{
if (!IsProjectLevel(package))
{
ReinstallSolutionPackage(package, updateDependencies, allowPrereleaseVersions, logger);
}
}
// Now, take care of project-level packages
var packagesInProject = new Dictionary<IProjectManager, HashSet<IPackage>>();
var verifiedPackagesInSourceRepository = new Dictionary<PackageName, IPackage>();
HashSet<IPackage> allPackagesToBeReinstalled = new HashSet<IPackage>();
// first uninstall all the packages from each project
RunActionOnProjects(
_solutionManager.GetProjects(),
project =>
{
IProjectManager projectManager = GetProjectManager(project);
HashSet<IPackage> packagesToBeReinstalled;
UninstallPackagesForReinstall(projectManager, updateDependencies, logger, verifiedPackagesInSourceRepository, out packagesToBeReinstalled);
Debug.Assert(!packagesInProject.ContainsKey(projectManager));
packagesInProject[projectManager] = packagesToBeReinstalled;
allPackagesToBeReinstalled.AddRange(packagesToBeReinstalled);
},
logger,
eventListener ?? NullPackageOperationEventListener.Instance);
// NOTE THAT allowPrereleaseVersions should be true for pre-release packages alone, even if the user did not specify it
// since we are trying to reinstall packages here. However, ResolveOperations below will take care of this problem via allowPrereleaseVersionsBasedOnPackage parameter
var installWalker = new InstallWalker(LocalRepository, SourceRepository, null, logger ?? NullLogger.Instance,
ignoreDependencies: !updateDependencies, allowPrereleaseVersions: allowPrereleaseVersions,
dependencyVersion: DependencyVersion);
IList<IPackage> packagesUninstalledInDependencyOrder;
var operations = installWalker.ResolveOperations(allPackagesToBeReinstalled, out packagesUninstalledInDependencyOrder, allowPrereleaseVersionsBasedOnPackage: true);
ExecuteOperationsWithPackage(
_solutionManager.GetProjects(),
null,
operations,
projectManager =>
{
foreach (var package in packagesUninstalledInDependencyOrder)
{
HashSet<IPackage> packagesToBeReinstalled;
if (packagesInProject.TryGetValue(projectManager, out packagesToBeReinstalled) && packagesToBeReinstalled.Contains(package))
{
AddPackageReference(projectManager, package, ignoreDependencies: !updateDependencies, allowPrereleaseVersions: allowPrereleaseVersions || !package.IsReleaseVersion());
}
}
},
logger,
eventListener);
}
开发者ID:Mailaender,项目名称:xamarin-nuget,代码行数:73,代码来源:VSPackageManager.cs
示例8: ShowLicenseAgreementForAllPackages
protected bool ShowLicenseAgreementForAllPackages(IVsPackageManager activePackageManager, out IList<PackageOperation> allOperations, out IList<IPackage> packagesByDependencyOrder)
{
allOperations = new List<PackageOperation>();
var installWalker = new InstallWalker(
LocalRepository,
activePackageManager.SourceRepository,
_project.GetTargetFrameworkName(),
logger: this,
ignoreDependencies: false,
allowPrereleaseVersions: IncludePrerelease,
dependencyVersion: activePackageManager.DependencyVersion);
var allPackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease);
allOperations = installWalker.ResolveOperations(allPackages, out packagesByDependencyOrder);
return ShowLicenseAgreement(activePackageManager, allOperations);
}
开发者ID:Newtopian,项目名称:nuget,代码行数:17,代码来源:UpdatesProvider.cs
示例9: ShowLicenseAgreement
protected bool ShowLicenseAgreement(
IPackage package,
IVsPackageManager packageManager,
FrameworkName targetFramework,
out IList<PackageOperation> operations)
{
var walker = new InstallWalker(
LocalRepository,
packageManager.SourceRepository,
targetFramework,
this,
ignoreDependencies: false,
allowPrereleaseVersions: IncludePrerelease,
dependencyVersion: packageManager.DependencyVersion);
operations = walker.ResolveOperations(package).ToList();
return ShowLicenseAgreement(packageManager, operations);
}
开发者ID:Newtopian,项目名称:nuget,代码行数:17,代码来源:PackagesProviderBase.cs
示例10: ResolveDependencyForInstallCircularReferenceWithDifferentVersionOfPackageReferenceThrows
public void ResolveDependencyForInstallCircularReferenceWithDifferentVersionOfPackageReferenceThrows()
{
// Arrange
var localRepository = new MockPackageRepository();
var sourceRepository = new MockPackageRepository();
IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
});
IPackage packageA15 = PackageUtility.CreatePackage("A", "1.5",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
});
IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("A", "[1.5]")
});
sourceRepository.AddPackage(packageA10);
sourceRepository.AddPackage(packageA15);
sourceRepository.AddPackage(packageB10);
IPackageOperationResolver resolver = new InstallWalker(localRepository,
sourceRepository,
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act & Assert
ExceptionAssert.Throws<InvalidOperationException>(() => resolver.ResolveOperations(packageA10), "Circular dependency detected 'A 1.0 => B 1.0 => A 1.5'.");
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:36,代码来源:PackageWalkerTest.cs
示例11: ResolveDependenciesForInstallCircularReferenceThrows
public void ResolveDependenciesForInstallCircularReferenceThrows()
{
// Arrange
var localRepository = new MockPackageRepository();
var sourceRepository = new MockPackageRepository();
IPackage packageA = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B")
});
IPackage packageB = PackageUtility.CreatePackage("B", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("A")
});
sourceRepository.AddPackage(packageA);
sourceRepository.AddPackage(packageB);
IPackageOperationResolver resolver = new InstallWalker(
localRepository,
new DependencyResolverFromRepo(sourceRepository),
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false,
dependencyVersion: DependencyVersion.Lowest);
// Act & Assert
ExceptionAssert.Throws<InvalidOperationException>(() => resolver.ResolveOperations(packageA), "Circular dependency detected 'A 1.0 => B 1.0 => A 1.0'.");
}
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:31,代码来源:PackageWalkerTest.cs
示例12: ResolveOperationsToInstallSolutionLevelPackage
private IEnumerable<PackageOperation> ResolveOperationsToInstallSolutionLevelPackage(Operation operation)
{
var repo = _virtualPackageRepos[operation.ProjectManager.PackageManager];
var installWalker = new InstallWalker(
repo,
operation.ProjectManager.PackageManager.DependencyResolver,
targetFramework: null,
logger: Logger,
ignoreDependencies: IgnoreDependencies,
allowPrereleaseVersions: AllowPrereleaseVersions,
dependencyVersion: DependencyVersion);
var operations = installWalker.ResolveOperations(operation.Package);
// we're installing solution level packages, so all target should be
// set to PackagesFolder.
foreach (var op in operations)
{
op.Target = PackageOperationTarget.PackagesFolder;
}
return operations;
}
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:22,代码来源:ActionResolver.cs
示例13: 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")));
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:78,代码来源:VsPackageManagerTest.cs
示例14: ResolveDependenciesForInstallDiamondDependencyGraph
public void ResolveDependenciesForInstallDiamondDependencyGraph()
{
// Arrange
var localRepository = new MockPackageRepository();
var sourceRepository = new MockPackageRepository();
// A -> [B, C]
// B -> [D]
// C -> [D]
// A
// / \
// B C
// \ /
// D
IPackage packageA = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B"),
new PackageDependency("C")
});
IPackage packageB = PackageUtility.CreatePackage("B", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("D")
});
IPackage packageC = PackageUtility.CreatePackage("C", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("D")
});
IPackage packageD = PackageUtility.CreatePackage("D", "1.0");
sourceRepository.AddPackage(packageA);
sourceRepository.AddPackage(packageB);
sourceRepository.AddPackage(packageC);
sourceRepository.AddPackage(packageD);
IPackageOperationResolver resolver = new InstallWalker(localRepository,
sourceRepository,
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act
var packages = resolver.ResolveOperations(packageA).ToList();
// Assert
var dict = packages.ToDictionary(p => p.Package.Id);
Assert.Equal(4, packages.Count);
Assert.NotNull(dict["A"]);
Assert.NotNull(dict["B"]);
Assert.NotNull(dict["C"]);
Assert.NotNull(dict["D"]);
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:55,代码来源:PackageWalkerTest.cs
示例15: ResolvingDependencyForUpdateThatHasAnUnsatisfiedConstraint
public void ResolvingDependencyForUpdateThatHasAnUnsatisfiedConstraint()
{
// Arrange
var localRepository = new MockPackageRepository();
var sourceRepository = new MockPackageRepository();
var constraintProvider = new Mock<IPackageConstraintProvider>();
constraintProvider.Setup(m => m.GetConstraint("B")).Returns(VersionUtility.ParseVersionSpec("[1.4]"));
constraintProvider.Setup(m => m.Source).Returns("foo");
IPackage A10 = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("B", "1.5")
});
IPackage A20 = PackageUtility.CreatePackage("A", "2.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("B", "2.0")
});
IPackage B15 = PackageUtility.CreatePackage("B", "1.5");
IPackage B20 = PackageUtility.CreatePackage("B", "2.0");
localRepository.Add(A10);
localRepository.Add(B15);
sourceRepository.AddPackage(A10);
sourceRepository.AddPackage(A20);
sourceRepository.AddPackage(B15);
sourceRepository.AddPackage(B20);
IPackageOperationResolver resolver = new InstallWalker(localRepository,
sourceRepository,
constraintProvider.Object,
null,
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act & Assert
ExceptionAssert.Throws<InvalidOperationException>(() => resolver.ResolveOperations(A20), "Unable to resolve dependency 'B (\u2265 2.0)'.'B' has an additional constraint (= 1.4) defined in foo.");
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:38,代码来源:PackageWalkerTest.cs
示例16: ResolveDependenciesForInstallDiamondDependencyGraphWithDifferntVersionOfSamePackage
public void ResolveDependenciesForInstallDiamondDependencyGraphWithDifferntVersionOfSamePackage()
{
// Arrange
var localRepository = new MockPackageRepository();
var sourceRepository = new MockPackageRepository();
// A -> [B, C]
// B -> [D >= 1, E >= 2]
// C -> [D >= 2, E >= 1]
// A
// / \
// B C
// | \ | \
// D1 E2 D2 E1
IPackage packageA = PackageUtility.CreateProjectLevelPackage("A", "1.0",
dependencies: new List<PackageDependency> {
new PackageDependency("B"),
new PackageDependency("C")
});
IPackage packageB = PackageUtility.CreateProjectLevelPackage("B", "1.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("D", "1.0"),
PackageDependency.CreateDependency("E", "2.0")
});
IPackage packageC = PackageUtility.CreateProjectLevelPackage("C", "1.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("D", "2.0"),
PackageDependency.CreateDependency("E", "1.0")
});
IPackage packageD10 = PackageUtility.CreateProjectLevelPackage("D", "1.0");
IPackage packageD20 = PackageUtility.CreateProjectLevelPackage("D", "2.0");
IPackage packageE10 = PackageUtility.CreateProjectLevelPackage("E", "1.0");
IPackage packageE20 = PackageUtility.CreateProjectLevelPackage("E", "2.0");
sourceRepository.AddPackage(packageA);
sourceRepository.AddPackage(packageB);
sourceRepository.AddPackage(packageC);
sourceRepository.AddPackage(packageD20);
sourceRepository.AddPackage(packageD10);
sourceRepository.AddPackage(packageE20);
sourceRepository.AddPackage(packageE10);
IPackageOperationResolver resolver = new InstallWalker(localRepository,
sourceRepository,
NullLogger.Instance,
ignoreDependencies: false,
allowPrereleaseVersions: false);
// Act
var operations = resolver.ResolveOperations(packageA).ToList();
var projectOperations = resolver.ResolveOperations(packageA).ToList();
// Assert
Assert.Equal(5, operations.Count);
Assert.Equal("E", operations[0].Package.Id);
Assert.Equal(new SemanticVersion("2.0"), operations[0].Package.Version);
Assert.Equal("B", operations[1].Package.Id);
Assert.Equal("D", operations[2].Package.Id);
Assert.Equal(new SemanticVersion("2.0"), operations[2].Package.Version);
Assert.Equal("C", operations[3].Package.Id);
Assert.Equal("A", operations[4].Package.Id);
Assert.Equal(5, projectOperations.Count);
Assert.Equal("E", projectOperations[0].Package.Id);
Assert.Equal(new SemanticVersion("2.0"), projectOperations[0].Package.Version);
Assert.Equal("B", projectOperations[1].Package.Id);
Assert.Equal("D", projectOperations[2].Package.Id);
Assert.Equal(new SemanticVersion("2.0"), projectOperations[2].Package.Version);
Assert.Equal("C", projectOperations[3].Package.Id);
Assert.Equal("A", projectOperations[4].Package.Id);
}
开发者ID:Berzeger,项目名称:NuGet,代码行数:76,代码来源:PackageWalkerTest.cs
示例17: ResolveOperationsForInstallSameDependencyAtDifferentLevelsInGraph
public void ResolveOperationsForInstallSameDependencyAtDifferentLevelsInGraph()
{
// Arrange
var localRepository = new MockPackageRepository();
var sourceRepository = new MockPackageRepository();
// A1 -> B1, C1
IPackage packageA = PackageUtility.CreatePackage("A", "1.0",
dependencies: new List<PackageDependency> {
PackageDependency.CreateDependency("B", "1.0"),
PackageDependency.CreateDependency("C", "1.0")
});
// B1
|
请发表评论