当前位置: 首页>>代码示例>>C#>>正文


C# Dependency.RefineVersionRange方法代码示例

本文整理汇总了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);
        }
开发者ID:googlesamples,项目名称:unity-jar-resolver,代码行数:70,代码来源:DependencyTests.cs


注:本文中的Dependency.RefineVersionRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。