public void GetIntersectionTest() { TimeBlock readOnlyTimeBlock = new TimeBlock(_start, _duration); Assert.AreEqual(readOnlyTimeBlock.GetIntersectionBlock(readOnlyTimeBlock), new TimeBlock(readOnlyTimeBlock)); TimeBlock timeBlock = new TimeBlock(_start, _duration); // before ITimeBlock before1 = timeBlock.GetIntersectionBlock(new TimeBlock(_start.AddHours(-2), _start.AddHours(-1))); Assert.AreEqual(before1, null); ITimeBlock before2 = timeBlock.GetIntersectionBlock(new TimeBlock(_start.AddMilliseconds(-1), _start)); Assert.AreEqual(before2, new TimeBlock(_start)); ITimeBlock before3 = timeBlock.GetIntersectionBlock(new TimeBlock(_start.AddMilliseconds(-1), _start.AddMilliseconds(1))); Assert.AreEqual(before3, new TimeBlock(_start, _start.AddMilliseconds(1))); // after ITimeBlock after1 = timeBlock.GetIntersectionBlock(new TimeBlock(_end.AddHours(1), _end.AddHours(2))); Assert.AreEqual(after1, null); ITimeBlock after2 = timeBlock.GetIntersectionBlock(new TimeBlock(_end, _end.AddMilliseconds(1))); Assert.AreEqual(after2, new TimeBlock(_end)); ITimeBlock after3 = timeBlock.GetIntersectionBlock(new TimeBlock(_end.AddMilliseconds(-1), _end.AddMilliseconds(1))); Assert.AreEqual(after3, new TimeBlock(_end.AddMilliseconds(-1), _end)); // intersect Assert.AreEqual(timeBlock.GetIntersectionBlock(timeBlock), timeBlock); ITimeBlock itersect1 = timeBlock.GetIntersectionBlock(new TimeBlock(_start.AddMilliseconds(-1), _end.AddMilliseconds(1))); Assert.AreEqual(itersect1, timeBlock); ITimeBlock itersect2 = timeBlock.GetIntersectionBlock(new TimeBlock(_start.AddMilliseconds(1), _end.AddMilliseconds(-1))); Assert.AreEqual(itersect2, new TimeBlock(_start.AddMilliseconds(1), _end.AddMilliseconds(-1))); }