本文整理汇总了C#中Dependency.RefineVersionRange方法的典型用法代码示例。如果您正苦于以下问题:C# Dependency.RefineVersionRange方法的具体用法?C# Dependency.RefineVersionRange怎么用?C# Dependency.RefineVersionRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dependency
的用法示例。
在下文中一共展示了Dependency.RefineVersionRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRefineVersionRange
public void TestRefineVersionRange()
{
Dependency dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
// refinement with the same object should have no effect.
Assert.True(dep.RefineVersionRange(dep));
Assert.True(dep.HasPossibleVersions);
Assert.True(dep.BestVersion == "2.2.0");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.0.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.IsNullOrEmpty(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
// refinement with a concrete version not compatible should fail.
dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
Dependency dep1 = new Dependency("test", "artifact1", "3.0");
Assert.False(dep.RefineVersionRange(dep1));
Assert.False(dep.HasPossibleVersions);
// concrete included
dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
Dependency dep2 = new Dependency("test", "artifact1", "2.1.0");
Assert.True(dep.RefineVersionRange(dep2));
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
// check overlapping ranges
dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
Dependency dep1plus = new Dependency("test", "artifact1", "2.1+");
Assert.True(dep.RefineVersionRange(dep1plus));
Assert.True(dep.BestVersion == "2.2.0");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
}