本文整理汇总了C#中Range.GetIntersection方法的典型用法代码示例。如果您正苦于以下问题:C# Range.GetIntersection方法的具体用法?C# Range.GetIntersection怎么用?C# Range.GetIntersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.GetIntersection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIntersectionShouldThrowExceptionIfItHasNoIntersection3
public void GetIntersectionShouldThrowExceptionIfItHasNoIntersection3()
{
var a = new Range<int>(3);
var b = new Range<int>(1, 2);
Assert.Throws<InvalidOperationException>(() => a.GetIntersection(b));
}
示例2: GetIntersectionShouldThrowExceptionIfItHasNoIntersection8
public void GetIntersectionShouldThrowExceptionIfItHasNoIntersection8()
{
var a = new Range<int>(4);
var b = new Range<int>(null, 3);
Assert.Throws<InvalidOperationException>(() => b.GetIntersection(a));
}
示例3: GetIntersectionShouldReturnValidRangeIfItHasIntersection
public void GetIntersectionShouldReturnValidRangeIfItHasIntersection()
{
var a = new Range<int>(1, 3);
var b = new Range<int>(2, 4);
var c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
a = new Range<int>(2, 3);
b = new Range<int>(1, 4);
c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
a = new Range<int>(1, 3);
b = new Range<int>(3, 4);
c = a.GetIntersection(b);
Assert.AreEqual(3, c.Start);
Assert.AreEqual(3, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(3, c.Start);
Assert.AreEqual(3, c.End);
a = new Range<int>(2, 3);
b = new Range<int>(1, 2);
c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(2, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(2, c.End);
a = new Range<int>(2, 3);
b = new Range<int>(2, 3);
c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
a = new Range<int>(2, 2);
b = new Range<int>(2, 2);
c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(2, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(2, c.End);
a = new Range<int>(1);
b = new Range<int>(2, 4);
c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(4, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(4, c.End);
a = new Range<int>(null, 3);
b = new Range<int>(2, 4);
c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.AreEqual(3, c.End);
a = new Range<int>(null, 3);
b = new Range<int>(null, 4);
c = a.GetIntersection(b);
Assert.IsNull(c.Start);
Assert.AreEqual(3, c.End);
c = b.GetIntersection(a);
Assert.IsNull(c.Start);
Assert.AreEqual(3, c.End);
a = new Range<int>(1);
b = new Range<int>(2);
c = a.GetIntersection(b);
Assert.AreEqual(2, c.Start);
Assert.IsNull(c.End);
c = b.GetIntersection(a);
Assert.AreEqual(2, c.Start);
Assert.IsNull(c.End);
a = new Range<int>(1);
b = new Range<int>(null, 4);
c = a.GetIntersection(b);
Assert.AreEqual(1, c.Start);
Assert.AreEqual(4, c.End);
c = b.GetIntersection(a);
Assert.AreEqual(1, c.Start);
Assert.AreEqual(4, c.End);
//.........这里部分代码省略.........