当前位置: 首页>>代码示例>>C#>>正文


C# TimeRange.IntersectsWith方法代码示例

本文整理汇总了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));
        }
开发者ID:darting,项目名称:MetricSystem,代码行数:9,代码来源:TimeRangeTests.cs

示例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));
        }
开发者ID:darting,项目名称:MetricSystem,代码行数:9,代码来源:TimeRangeTests.cs

示例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));
        }
开发者ID:darting,项目名称:MetricSystem,代码行数:11,代码来源:TimeRangeTests.cs

示例4: TestTimeRangeIntersectExactOverlap

        public void TestTimeRangeIntersectExactOverlap()
        {
            var now = DateTime.Now;
            var rangeA = new TimeRange(now, now.AddMinutes(1));

            Assert.IsTrue(rangeA.IntersectsWith(rangeA));
        }
开发者ID:darting,项目名称:MetricSystem,代码行数:7,代码来源:TimeRangeTests.cs

示例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));
        }
开发者ID:debop,项目名称:NFramework,代码行数:35,代码来源:TimeRangeFixture.cs


注:本文中的TimeRange.IntersectsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。