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 ) ); }
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 ) ) ); }