本文整理汇总了C#中PackageIdentity.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# PackageIdentity.Equals方法的具体用法?C# PackageIdentity.Equals怎么用?C# PackageIdentity.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageIdentity
的用法示例。
在下文中一共展示了PackageIdentity.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPacManPreviewUpdatePackagesSimple
public async Task TestPacManPreviewUpdatePackagesSimple()
{
// Arrange
var sourceRepositoryProvider = TestSourceRepositoryUtility.CreateV2OnlySourceRepositoryProvider();
var testSolutionManager = new TestSolutionManager();
var testSettings = new NullSettings();
var token = CancellationToken.None;
var nuGetPackageManager = new NuGetPackageManager(sourceRepositoryProvider, testSettings, testSolutionManager);
var packagesFolderPath = PackagesFolderPathUtility.GetPackagesFolderPath(testSolutionManager, testSettings);
var randomPackagesConfigFolderPath = TestFilesystemUtility.CreateRandomTestFolder();
var randomPackagesConfigPath = Path.Combine(randomPackagesConfigFolderPath, "packages.config");
var projectTargetFramework = NuGetFramework.Parse("net45");
var msBuildNuGetProjectSystem = new TestMSBuildNuGetProjectSystem(projectTargetFramework, new TestNuGetProjectContext());
var msBuildNuGetProject = new MSBuildNuGetProject(msBuildNuGetProjectSystem, packagesFolderPath, randomPackagesConfigPath);
var packageIdentity0 = PackageWithDependents[0]; // jQuery.1.4.4
var resolutionContext = new ResolutionContext();
var latestVersion = await NuGetPackageManager.GetLatestVersionAsync(packageIdentity0.Id, new ResolutionContext(),
sourceRepositoryProvider.GetRepositories().First(), token);
var packageLatest = new PackageIdentity(packageIdentity0.Id, latestVersion);
// Pre-Assert
// Check that the packages.config file does not exist
Assert.False(File.Exists(randomPackagesConfigPath));
// Check that there are no packages returned by PackagesConfigProject
var packagesInPackagesConfig = (await msBuildNuGetProject.PackagesConfigNuGetProject.GetInstalledPackagesAsync(token)).ToList();
Assert.Equal(0, packagesInPackagesConfig.Count);
Assert.Equal(0, msBuildNuGetProjectSystem.References.Count);
// Act
await nuGetPackageManager.InstallPackageAsync(msBuildNuGetProject, packageIdentity0,
resolutionContext, new TestNuGetProjectContext(), sourceRepositoryProvider.GetRepositories().First(), null, token);
// Assert
// Check that the packages.config file exists after the installation
Assert.True(File.Exists(randomPackagesConfigPath));
// Check the number of packages and packages returned by PackagesConfigProject after the installation
packagesInPackagesConfig = (await msBuildNuGetProject.PackagesConfigNuGetProject.GetInstalledPackagesAsync(token)).ToList();
Assert.Equal(1, packagesInPackagesConfig.Count);
Assert.Equal(packageIdentity0, packagesInPackagesConfig[0].PackageIdentity);
Assert.Equal(projectTargetFramework, packagesInPackagesConfig[0].TargetFramework);
var installedPackageIds = (await msBuildNuGetProject.GetInstalledPackagesAsync(token))
.Select(pr => pr.PackageIdentity.Id);
// Main Act
var packageActions = (await nuGetPackageManager.PreviewUpdatePackagesAsync(installedPackageIds, msBuildNuGetProject,
new ResolutionContext(DependencyBehavior.Highest), new TestNuGetProjectContext(), sourceRepositoryProvider.GetRepositories().First(),
null, token)).ToList();
// Assert
Assert.Equal(2, packageActions.Count);
Assert.True(packageIdentity0.Equals(packageActions[0].PackageIdentity));
Assert.Equal(NuGetProjectActionType.Uninstall, packageActions[0].NuGetProjectActionType);
Assert.True(packageLatest.Equals(packageActions[1].PackageIdentity));
Assert.Equal(NuGetProjectActionType.Install, packageActions[1].NuGetProjectActionType);
Assert.Equal(sourceRepositoryProvider.GetRepositories().Single().PackageSource.Source,
packageActions[1].SourceRepository.PackageSource.Source);
// Clean-up
TestFilesystemUtility.DeleteRandomTestFolders(testSolutionManager.SolutionDirectory, randomPackagesConfigFolderPath);
}