public void GetIntersectionTest() { TimeBlock readOnlyTimeBlock = new TimeBlock(start, duration); Assert.Equal(readOnlyTimeBlock.GetIntersection(readOnlyTimeBlock), new TimeBlock(readOnlyTimeBlock)); TimeBlock timeBlock = new TimeBlock(start, duration); // before ITimeBlock before1 = timeBlock.GetIntersection(new TimeBlock(start.AddHours(-2), start.AddHours(-1))); Assert.Null(before1); ITimeBlock before2 = timeBlock.GetIntersection(new TimeBlock(start.AddMilliseconds(-1), start)); Assert.Equal(before2, new TimeBlock(start)); ITimeBlock before3 = timeBlock.GetIntersection(new TimeBlock(start.AddMilliseconds(-1), start.AddMilliseconds(1))); Assert.Equal(before3, new TimeBlock(start, start.AddMilliseconds(1))); // after ITimeBlock after1 = timeBlock.GetIntersection(new TimeBlock(end.AddHours(1), end.AddHours(2))); Assert.Null(after1); ITimeBlock after2 = timeBlock.GetIntersection(new TimeBlock(end, end.AddMilliseconds(1))); Assert.Equal(after2, new TimeBlock(end)); ITimeBlock after3 = timeBlock.GetIntersection(new TimeBlock(end.AddMilliseconds(-1), end.AddMilliseconds(1))); Assert.Equal(after3, new TimeBlock(end.AddMilliseconds(-1), end)); // intersect Assert.Equal(timeBlock.GetIntersection(timeBlock), timeBlock); ITimeBlock itersect1 = timeBlock.GetIntersection(new TimeBlock(start.AddMilliseconds(-1), end.AddMilliseconds(1))); Assert.Equal(itersect1, timeBlock); ITimeBlock itersect2 = timeBlock.GetIntersection(new TimeBlock(start.AddMilliseconds(1), end.AddMilliseconds(-1))); Assert.Equal(itersect2, new TimeBlock(start.AddMilliseconds(1), end.AddMilliseconds(-1))); } // GetIntersectionTest