public void EternityInterrupted() { var items = new List <Interval> { new Interval(DateTimeOffset.MinValue, DateTimeOffset.MaxValue), new Interval(DateTime.Parse("2019/01/08"), DateTime.Parse("2019/01/10")), }; var joines = SetUtils.Merge(items); joines.Select(x => x.ToString()).Should().BeEquivalentTo( "01/01/0001 => 08/01/2019", "08/01/2019 => 10/01/2019", "10/01/2019 => 31/12/9999"); }
public void Breaking() { var input = @"01/01/2017 +00:00 31/01/2017 +00:00 01/02/2017 +00:00 28/02/2017 +00:00 "; var intervals = from line in input.Lines() let split = line.Split("\t") let start = split[0] let end = split[1] select new Interval(DateTimeOffset.Parse(start), DateTimeOffset.Parse(end)); var joines = SetUtils.Merge(intervals); joines.Select(x => x.ToString()).Should().BeEquivalentTo( "01/01/2017 => 31/01/2017", "01/02/2017 => 28/02/2017"); }
public void Complex() { var items = new List <Interval> { new Interval(DateTime.Parse("2019/01/1"), DateTime.Parse("2019/01/15")), new Interval(DateTime.Parse("2019/01/08"), DateTime.Parse("2019/01/10")), new Interval(DateTime.Parse("2019/01/16"), DateTime.Parse("2019/01/31")), new Interval(DateTime.Parse("2019/01/20"), DateTime.Parse("2019/01/20")) }; var joines = SetUtils.Merge(items); joines.Select(x => x.ToString()).Should().BeEquivalentTo(new[] { "01/01/2019 => 08/01/2019", "08/01/2019 => 10/01/2019", "10/01/2019 => 15/01/2019", "16/01/2019 => 20/01/2019", "20/01/2019 => 20/01/2019", "20/01/2019 => 31/01/2019", }); }