예제 #1
0
        public void Union_04()
        {
            var now = DateTime.Now;
            var c1  = new DateRangeCollection(
                new DateRange(now.AddHours(1), now.AddHours(40)));
            var c2 = new DateRangeCollection(
                new DateRange(now.AddHours(2), now.AddHours(4)),
                new DateRange(now.AddHours(5), now.AddHours(6)),
                new DateRange(now.AddHours(8), now.AddHours(10)));
            var result = c1.Union(c2);

            Assert.Single(result);
            Assert.Equal(now.AddHours(1), result.First().Start);
            Assert.Equal(now.AddHours(40), result.First().End);
        }
예제 #2
0
        public void Union_02()
        {
            var now = DateTime.Now;
            var c1  = new DateRangeCollection(
                new DateRange(now.AddHours(1), now.AddHours(6)),
                new DateRange(now.AddHours(5), now.AddHours(7)));
            var c2 = new DateRangeCollection(
                new DateRange(now.AddHours(9), now.AddHours(11)),
                new DateRange(now.AddHours(13), now.AddHours(15)));
            var result = c1.Union(c2);

            Assert.Equal(3, result.Count);
            Assert.Equal(now.AddHours(1), result.First().Start);
            Assert.Equal(now.AddHours(7), result.First().End);
            Assert.Equal(now.AddHours(9), result[1].Start);
            Assert.Equal(now.AddHours(11), result[1].End);
            Assert.Equal(now.AddHours(13), result[2].Start);
            Assert.Equal(now.AddHours(15), result[2].End);
        }