public void Intersections() { var now = DateTime.UtcNow; var intervals = new IntervalCollection(); intervals.Add(new Interval(now, TimeSpan.FromHours(1))); intervals.Add(new Interval(now.AddDays(10), TimeSpan.FromHours(1))); Assert.IsTrue(intervals.GetIntersections().Count() == 0); intervals.Clear(); intervals.Add(new Interval(now, TimeSpan.FromHours(2))); intervals.Add(new Interval(now.AddHours(-0.5), TimeSpan.FromHours(1))); var intersection = intervals.GetIntersections().Single(); Assert.AreEqual(now, intersection.Start); Assert.AreEqual(TimeSpan.FromHours(0.5), intersection.Length); }