IntersectsWith() 공개 메소드

public IntersectsWith ( ITimePeriod test ) : bool
test ITimePeriod
리턴 bool
예제 #1
0
        public void IntersectsWithDateTimeTest()
        {
            TimeRange timeRange = new TimeRange( start, end );

            // before
            TimeRange before1 = new TimeRange( start.AddHours( -2 ), start.AddHours( -1 ) );
            Assert.IsFalse( timeRange.IntersectsWith( before1 ) );
            TimeRange before2 = new TimeRange( start.AddMilliseconds( -1 ), start );
            Assert.IsTrue( timeRange.IntersectsWith( before2 ) );
            TimeRange before3 = new TimeRange( start.AddMilliseconds( -1 ), start.AddMilliseconds( 1 ) );
            Assert.IsTrue( timeRange.IntersectsWith( before3 ) );

            // after
            TimeRange after1 = new TimeRange( end.AddHours( 1 ), end.AddHours( 2 ) );
            Assert.IsFalse( timeRange.IntersectsWith( after1 ) );
            TimeRange after2 = new TimeRange( end, end.AddMilliseconds( 1 ) );
            Assert.IsTrue( timeRange.IntersectsWith( after2 ) );
            TimeRange after3 = new TimeRange( end.AddMilliseconds( -1 ), end.AddMilliseconds( 1 ) );
            Assert.IsTrue( timeRange.IntersectsWith( after3 ) );

            // intersect
            Assert.IsTrue( timeRange.IntersectsWith( timeRange ) );
            TimeRange itersect1 = new TimeRange( start.AddMilliseconds( -1 ), end.AddMilliseconds( 1 ) );
            Assert.IsTrue( timeRange.IntersectsWith( itersect1 ) );
            TimeRange itersect2 = new TimeRange( start.AddMilliseconds( -1 ), start.AddMilliseconds( 1 ) );
            Assert.IsTrue( timeRange.IntersectsWith( itersect2 ) );
            TimeRange itersect3 = new TimeRange( end.AddMilliseconds( -1 ), end.AddMilliseconds( 1 ) );
            Assert.IsTrue( timeRange.IntersectsWith( itersect3 ) );
        }