本文整理汇总了C#中Prefix.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Prefix.CompareTo方法的具体用法?C# Prefix.CompareTo怎么用?C# Prefix.CompareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prefix
的用法示例。
在下文中一共展示了Prefix.CompareTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualityTest
public void EqualityTest()
{
var p1 = new Prefix(_prefixConfig, "DEV", "iphone");
var p2 = new Prefix(_prefixConfig, "DEV");
var p3 = new Prefix(_prefixConfig, "stageB");
var p4 = new Prefix(_prefixConfig, "DEV", "iphone");
Assert.IsTrue(p1.CompareTo(p2) > 0);
Assert.IsTrue(p1.CompareTo(p3) > 0);
Assert.IsTrue(p2.CompareTo(p3) > 0);
Assert.AreNotEqual(p1, p2);
Assert.AreEqual(p1, p4);
}
示例2: CompareTest
public void CompareTest()
{
var p1 = new Prefix(_prefixConfig, "DEV", "iphone");
var p2 = new Prefix(_prefixConfig, "DEV");
var p3 = new Prefix(_prefixConfig, "stageB");
var p4 = new Prefix(_prefixConfig, "DEV", "iphone");
var p5 = new Prefix(_prefixConfig, "ios", "iphone");
var prefixes = new [] {p1, p2, p3, p4, p5};
var max = prefixes.Max();
var min = prefixes.Min();
Assert.AreEqual(max, p1);
Assert.AreEqual(min, p3);
Assert.IsTrue(p2.CompareTo(p5) < 0);
}
示例3: TestPrefixComparison
public void TestPrefixComparison()
{
// Object setup
object obj1 = new object();
Prefix p1 = new Prefix();
Prefix p2 = new Prefix();
Prefix p3 = new Prefix("Hello", "World", "Foobar");
Prefix p4 = new Prefix("Hello", "World", "Foobar");
Prefix p5 = new Prefix("Hello");
try
{
p1.CompareTo(obj1);
Assert.Fail("Comparison with a non Prefix object should throw ArgumentException");
}
catch (ArgumentException)
{
// Expected exception
}
// Equal
Assert.AreEqual(0, p1.CompareTo(p2));
Assert.AreEqual(0, p2.CompareTo(p1));
Assert.AreEqual(0, p3.CompareTo(p4));
Assert.AreEqual(0, p4.CompareTo(p3));
// Not equal
Assert.IsTrue(0 > p1.CompareTo(p3));
Assert.IsTrue(0 < p3.CompareTo(p1));
Assert.IsTrue(0 > p2.CompareTo(p4));
Assert.IsTrue(0 < p4.CompareTo(p2));
Assert.IsTrue(0 < p4.CompareTo(p5));
Assert.IsTrue(0 > p5.CompareTo(p4));
}