本文整理汇总了C#中Location.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Location.CompareTo方法的具体用法?C# Location.CompareTo怎么用?C# Location.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.CompareTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: check_that_the_CompareTo_method_works
public void check_that_the_CompareTo_method_works()
{
Location loc1 = new Location(5, 6);
Location loc2 = new Location(5, 6);
Location loc3 = new Location(7, 5);
Location loc4 = new Location(6, 5);
Location loc5 = new Location(6, 6);
Location loc6 = new Location(6, 4);
Specify.That(loc1.CompareTo(loc2)).ShouldEqual(0);
Specify.That(loc1.CompareTo(loc3)).ShouldEqual(-1);
Specify.That(loc1.CompareTo(loc4)).ShouldEqual(-1);
Specify.That(loc3.CompareTo(loc4)).ShouldEqual(1);
Specify.That(loc4.CompareTo(loc5)).ShouldEqual(-1);
Specify.That(loc4.CompareTo(loc6)).ShouldEqual(1);
}
示例2: CompareLocation_SameXandY_ResturnsSame
public void CompareLocation_SameXandY_ResturnsSame()
{
//Arrange
Location location1 = new Location(100, 500);
Location location2 = new Location(100, 500);
//Act
//Assert
Assert.AreEqual(0, location1.CompareTo(location2));
}
示例3: CompareLocation_SmallXVsLargeX_ResturnsSmaller
public void CompareLocation_SmallXVsLargeX_ResturnsSmaller()
{
//Arrange
Location location1 = new Location(100, 100);
Location location2 = new Location(200, 100);
//Act
//Assert
Assert.AreEqual(-1, location1.CompareTo(location2));
}
示例4: CompareLocation_LargeYVsSmallY_ResturnsSmaller
public void CompareLocation_LargeYVsSmallY_ResturnsSmaller()
{
//Arrange
Location location1 = new Location(100, 500);
Location location2 = new Location(100, 100);
//Act
//Assert
Assert.AreEqual(1, location1.CompareTo(location2));
}