HasInside() public method

public HasInside ( System.DateTime test ) : bool
test System.DateTime
return bool
Beispiel #1
0
        public void HasInsidePeriodTest()
        {
            TimeBlock timeBlock = new TimeBlock( start, duration );
            Assert.AreEqual( timeBlock.Duration, duration );

            // before
            TimeBlock before1 = new TimeBlock( start.AddHours( -2 ), start.AddHours( -1 ) );
            Assert.IsFalse( timeBlock.HasInside( before1 ) );
            TimeBlock before2 = new TimeBlock( start.AddMilliseconds( -1 ), end );
            Assert.IsFalse( timeBlock.HasInside( before2 ) );
            TimeBlock before3 = new TimeBlock( start.AddMilliseconds( -1 ), start );
            Assert.IsFalse( timeBlock.HasInside( before3 ) );

            // after
            TimeBlock after1 = new TimeBlock( end.AddHours( 1 ), end.AddHours( 2 ) );
            Assert.IsFalse( timeBlock.HasInside( after1 ) );
            TimeBlock after2 = new TimeBlock( start, end.AddMilliseconds( 1 ) );
            Assert.IsFalse( timeBlock.HasInside( after2 ) );
            TimeBlock after3 = new TimeBlock( end, end.AddMilliseconds( 1 ) );
            Assert.IsFalse( timeBlock.HasInside( after3 ) );

            // inside
            Assert.IsTrue( timeBlock.HasInside( timeBlock ) );
            TimeBlock inside1 = new TimeBlock( start.AddMilliseconds( 1 ), end );
            Assert.IsTrue( timeBlock.HasInside( inside1 ) );
            TimeBlock inside2 = new TimeBlock( start.AddMilliseconds( 1 ), end.AddMilliseconds( -1 ) );
            Assert.IsTrue( timeBlock.HasInside( inside2 ) );
            TimeBlock inside3 = new TimeBlock( start, end.AddMilliseconds( -1 ) );
            Assert.IsTrue( timeBlock.HasInside( inside3 ) );
        }
Beispiel #2
0
        public void HasInsideDateTimeTest()
        {
            TimeBlock timeBlock = new TimeBlock( start, duration );
            Assert.AreEqual( timeBlock.Duration, duration );

            // start
            Assert.IsFalse( timeBlock.HasInside( start.AddMilliseconds( -1 ) ) );
            Assert.IsTrue( timeBlock.HasInside( start ) );
            Assert.IsTrue( timeBlock.HasInside( start.AddMilliseconds( 1 ) ) );

            // end
            Assert.IsTrue( timeBlock.HasInside( end.AddMilliseconds( -1 ) ) );
            Assert.IsTrue( timeBlock.HasInside( end ) );
            Assert.IsFalse( timeBlock.HasInside( end.AddMilliseconds( 1 ) ) );
        }