本文整理汇总了C#中TimeInterval.HasInside方法的典型用法代码示例。如果您正苦于以下问题:C# TimeInterval.HasInside方法的具体用法?C# TimeInterval.HasInside怎么用?C# TimeInterval.HasInside使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeInterval
的用法示例。
在下文中一共展示了TimeInterval.HasInside方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasInsidePeriodTest
public void HasInsidePeriodTest() {
TimeInterval timeInterval = new TimeInterval(start, end);
Assert.AreEqual(timeInterval.End, end);
// before
TimeInterval before1 = new TimeInterval(start.AddHours(-2), start.AddHours(-1));
Assert.IsFalse(timeInterval.HasInside(before1));
TimeInterval before2 = new TimeInterval(start.AddMilliseconds(-1), end);
Assert.IsFalse(timeInterval.HasInside(before2));
TimeInterval before3 = new TimeInterval(start.AddMilliseconds(-1), start);
Assert.IsFalse(timeInterval.HasInside(before3));
// after
TimeInterval after1 = new TimeInterval(end.AddHours(1), end.AddHours(2));
Assert.IsFalse(timeInterval.HasInside(after1));
TimeInterval after2 = new TimeInterval(start, end.AddMilliseconds(1));
Assert.IsFalse(timeInterval.HasInside(after2));
TimeInterval after3 = new TimeInterval(end, end.AddMilliseconds(1));
Assert.IsFalse(timeInterval.HasInside(after3));
// inside
Assert.IsTrue(timeInterval.HasInside(timeInterval));
TimeInterval inside1 = new TimeInterval(start.AddMilliseconds(1), end);
Assert.IsTrue(timeInterval.HasInside(inside1));
TimeInterval inside2 = new TimeInterval(start.AddMilliseconds(1), end.AddMilliseconds(-1));
Assert.IsTrue(timeInterval.HasInside(inside2));
TimeInterval inside3 = new TimeInterval(start, end.AddMilliseconds(-1));
Assert.IsTrue(timeInterval.HasInside(inside3));
}
示例2: HasInsideDateTimeTest
public void HasInsideDateTimeTest() {
TimeInterval timeInterval = new TimeInterval(start, end);
Assert.AreEqual(timeInterval.End, end);
// start
Assert.IsFalse(timeInterval.HasInside(start.AddMilliseconds(-1)));
Assert.IsTrue(timeInterval.HasInside(start));
Assert.IsTrue(timeInterval.HasInside(start.AddMilliseconds(1)));
// end
Assert.IsTrue(timeInterval.HasInside(end.AddMilliseconds(-1)));
Assert.IsTrue(timeInterval.HasInside(end));
Assert.IsFalse(timeInterval.HasInside(end.AddMilliseconds(1)));
}