本文整理汇总了C#中PackageReferenceRepository.TryFindLatestPackageById方法的典型用法代码示例。如果您正苦于以下问题:C# PackageReferenceRepository.TryFindLatestPackageById方法的具体用法?C# PackageReferenceRepository.TryFindLatestPackageById怎么用?C# PackageReferenceRepository.TryFindLatestPackageById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageReferenceRepository
的用法示例。
在下文中一共展示了PackageReferenceRepository.TryFindLatestPackageById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PackageReferenceRepositoryDoNotFindLatestPackageIfItDoesNotExist
public void PackageReferenceRepositoryDoNotFindLatestPackageIfItDoesNotExist()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A", "1.0");
var packageB = PackageUtility.CreatePackage("B", "2.0");
var packageC = PackageUtility.CreatePackage("A", "1.5");
var packageD = PackageUtility.CreatePackage("A", "2.0-beta");
repository.Object.AddPackage(packageA);
repository.Object.AddPackage(packageB);
repository.Object.AddPackage(packageC);
repository.Object.AddPackage(packageD);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
<package id=""B"" version=""2.0"" />
<package id=""A"" version=""1.5"" />
<package id=""A"" version=""2.0-beta"" />
</packages>");
ILatestPackageLookup referenceRepository = new PackageReferenceRepository(
fileSystem,
repository.Object);
// Act
SemanticVersion latestVersion;
bool result = referenceRepository.TryFindLatestPackageById("C", out latestVersion);
// Assert
Assert.False(result);
Assert.Null(latestVersion);
}
示例2: GetPackageReferencesFindTheOnlyVersionAsLatestVersion
public void GetPackageReferencesFindTheOnlyVersionAsLatestVersion()
{
// Arrange
var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.3.4"" />
<package id=""A"" version=""2.5-beta"" />
<package id=""B"" version=""1.0"" />
<package id=""C"" version=""2.1.4"" />
</packages>";
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", config);
var sharedRepository = new Mock<MockPackageRepository>().As<ISharedPackageRepository>();
var packageReferenceRepository = new PackageReferenceRepository(fileSystem, sharedRepository.Object);
// Act
SemanticVersion version;
bool result = packageReferenceRepository.TryFindLatestPackageById("B", out version);
// Assert
Assert.True(result);
Assert.Equal(new SemanticVersion("1.0"), version);
}
示例3: GetPackageReferencesReturnsFalseForNonExistentId
public void GetPackageReferencesReturnsFalseForNonExistentId()
{
// Arrange
var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.3.4"" />
<package id=""A"" version=""2.5-beta"" />
<package id=""B"" version=""1.0"" />
<package id=""C"" version=""2.1.4"" />
</packages>";
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", config);
var sharedRepository = new Mock<MockPackageRepository>().As<ISharedPackageRepository>();
var packageReferenceRepository = new PackageReferenceRepository(fileSystem, sharedRepository.Object);
// Act
SemanticVersion version;
bool result = packageReferenceRepository.TryFindLatestPackageById("does-not-exist", out version);
// Assert
Assert.False(result);
Assert.Null(version);
}
示例4: PackageReferenceRepositoryFindTheOnlyPackageAsLatestPackage
public void PackageReferenceRepositoryFindTheOnlyPackageAsLatestPackage()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A", "1.0");
var packageB = PackageUtility.CreatePackage("B", "2.0");
var packageC = PackageUtility.CreatePackage("A", "1.5");
var packageD = PackageUtility.CreatePackage("A", "2.0-beta");
repository.Object.AddPackage(packageA);
repository.Object.AddPackage(packageB);
repository.Object.AddPackage(packageC);
repository.Object.AddPackage(packageD);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
<package id=""B"" version=""2.0"" />
<package id=""A"" version=""1.5"" />
<package id=""A"" version=""2.0-beta"" />
</packages>");
ILatestPackageLookup referenceRepository = new PackageReferenceRepository(fileSystem, projectName: null, sourceRepository: repository.Object);
// Act
SemanticVersion latestVersion;
bool result = referenceRepository.TryFindLatestPackageById("B", out latestVersion);
// Assert
Assert.True(result);
Assert.Equal(new SemanticVersion("2.0"), latestVersion);
}