本文整理汇总了C#中TimeRange.IntersectsWith方法的典型用法代码示例。如果您正苦于以下问题:C# TimeRange.IntersectsWith方法的具体用法?C# TimeRange.IntersectsWith怎么用?C# TimeRange.IntersectsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeRange
的用法示例。
在下文中一共展示了TimeRange.IntersectsWith方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestTimeRangeIntersectImmediatelyAdjacent
public void TestTimeRangeIntersectImmediatelyAdjacent()
{
var now = DateTime.Now;
var rangeA = new TimeRange(now, now.AddMinutes(2));
var rangeB = new TimeRange(now.AddMinutes(-2), now);
Assert.IsFalse(rangeA.IntersectsWith(rangeB));
Assert.IsFalse(rangeB.IntersectsWith(rangeA));
}
示例2: TestTimeRangeIntersectSubsetOverlap
public void TestTimeRangeIntersectSubsetOverlap()
{
var now = DateTime.Now;
var rangeA = new TimeRange(now, now.AddMinutes(20));
var rangeB = new TimeRange(now.AddMinutes(5), now.AddMinutes(10));
Assert.IsTrue(rangeA.IntersectsWith(rangeB));
Assert.IsTrue(rangeB.IntersectsWith(rangeA));
}
示例3: TestTimeRangeIntersectWithNoOverlap
public void TestTimeRangeIntersectWithNoOverlap()
{
var now = DateTime.Now;
var yesterday = now.AddDays(-1);
var rangeA = new TimeRange(now, now.AddMinutes(1));
var rangeB = new TimeRange(yesterday, yesterday.AddMinutes(1));
Assert.IsFalse(rangeA.IntersectsWith(rangeB));
Assert.IsFalse(rangeB.IntersectsWith(rangeA));
}
示例4: TestTimeRangeIntersectExactOverlap
public void TestTimeRangeIntersectExactOverlap()
{
var now = DateTime.Now;
var rangeA = new TimeRange(now, now.AddMinutes(1));
Assert.IsTrue(rangeA.IntersectsWith(rangeA));
}
示例5: IntersectsWithDateTimeTest
public void IntersectsWithDateTimeTest() {
TimeRange timeRange = new TimeRange(_start, _end);
// before
var before1 = new TimeRange(_start.AddHours(-2), _start.AddHours(-1));
Assert.IsFalse(timeRange.IntersectsWith(before1));
var before2 = new TimeRange(_start.AddMilliseconds(-1), _start);
Assert.IsTrue(timeRange.IntersectsWith(before2));
var before3 = new TimeRange(_start.AddMilliseconds(-1), _start.AddMilliseconds(1));
Assert.IsTrue(timeRange.IntersectsWith(before3));
// after
var after1 = new TimeRange(_end.AddHours(1), _end.AddHours(2));
Assert.IsFalse(timeRange.IntersectsWith(after1));
var after2 = new TimeRange(_end, _end.AddMilliseconds(1));
Assert.IsTrue(timeRange.IntersectsWith(after2));
var after3 = new TimeRange(_end.AddMilliseconds(-1), _end.AddMilliseconds(1));
Assert.IsTrue(timeRange.IntersectsWith(after3));
// intersect
Assert.IsTrue(timeRange.IntersectsWith(timeRange));
var itersect1 = new TimeRange(_start.AddMilliseconds(-1), _end.AddMilliseconds(1));
Assert.IsTrue(timeRange.IntersectsWith(itersect1));
var itersect2 = new TimeRange(_start.AddMilliseconds(-1), _start.AddMilliseconds(1));
Assert.IsTrue(timeRange.IntersectsWith(itersect2));
var itersect3 = new TimeRange(_end.AddMilliseconds(-1), _end.AddMilliseconds(1));
Assert.IsTrue(timeRange.IntersectsWith(itersect3));
}