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)); }
public void HasInsidePeriodTest() { TimeBlock timeBlock = new TimeBlock(start, duration); Assert.Equal <TimeSpan>(timeBlock.Duration, duration); // before TimeBlock before1 = new TimeBlock(start.AddHours(-2), start.AddHours(-1)); Assert.False(timeBlock.HasInside(before1)); TimeBlock before2 = new TimeBlock(start.AddMilliseconds(-1), end); Assert.False(timeBlock.HasInside(before2)); TimeBlock before3 = new TimeBlock(start.AddMilliseconds(-1), start); Assert.False(timeBlock.HasInside(before3)); // after TimeBlock after1 = new TimeBlock(end.AddHours(1), end.AddHours(2)); Assert.False(timeBlock.HasInside(after1)); TimeBlock after2 = new TimeBlock(start, end.AddMilliseconds(1)); Assert.False(timeBlock.HasInside(after2)); TimeBlock after3 = new TimeBlock(end, end.AddMilliseconds(1)); Assert.False(timeBlock.HasInside(after3)); // inside Assert.True(timeBlock.HasInside(timeBlock)); TimeBlock inside1 = new TimeBlock(start.AddMilliseconds(1), end); Assert.True(timeBlock.HasInside(inside1)); TimeBlock inside2 = new TimeBlock(start.AddMilliseconds(1), end.AddMilliseconds(-1)); Assert.True(timeBlock.HasInside(inside2)); TimeBlock inside3 = new TimeBlock(start, end.AddMilliseconds(-1)); Assert.True(timeBlock.HasInside(inside3)); } // HasInsidePeriodTest
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))); }
public void HasInsideDateTimeTest() { TimeBlock timeBlock = new TimeBlock(start, duration); Assert.Equal(timeBlock.Duration, duration); // start Assert.False(timeBlock.HasInside(start.AddMilliseconds(-1))); Assert.True(timeBlock.HasInside(start)); Assert.True(timeBlock.HasInside(start.AddMilliseconds(1))); // end Assert.True(timeBlock.HasInside(end.AddMilliseconds(-1))); Assert.True(timeBlock.HasInside(end)); Assert.False(timeBlock.HasInside(end.AddMilliseconds(1))); } // HasInsideDateTimeTest