本文整理汇总了C#中PackageReferenceRepository.GetConstraint方法的典型用法代码示例。如果您正苦于以下问题:C# PackageReferenceRepository.GetConstraint方法的具体用法?C# PackageReferenceRepository.GetConstraint怎么用?C# PackageReferenceRepository.GetConstraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageReferenceRepository
的用法示例。
在下文中一共展示了PackageReferenceRepository.GetConstraint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetConstraintThrowsIfConstrainInvalid
public void GetConstraintThrowsIfConstrainInvalid()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" allowedVersions=""[-1.3, 3)"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, repository.Object);
// Act & Assert
ExceptionAssert.Throws<InvalidDataException>(() => referenceRepository.GetConstraint("A"), "Unable to parse version value '[-1.3, 3)' from 'packages.config'.");
}
示例2: GetConstraintReturnsConstraintListedForPackageIdInPackagesConfig
public void GetConstraintReturnsConstraintListedForPackageIdInPackagesConfig()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" allowedVersions=""[1.0, 3.0)"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, repository.Object);
// Act
IVersionSpec constraint = referenceRepository.GetConstraint("A");
// Assert
Assert.NotNull(constraint);
Assert.True(constraint.IsMinInclusive);
Assert.False(constraint.IsMaxInclusive);
Assert.Equal(new SemanticVersion("1.0"), constraint.MinVersion);
Assert.Equal(new SemanticVersion("3.0"), constraint.MaxVersion);
}