Exemple #1
0
        public void Intersection_06()
        {
            var now = DateTime.Now;
            var c1  = new DateRangeCollection(
                new DateRange(now.AddMinutes(5), now.AddMinutes(10)));
            var c2 = new DateRangeCollection(
                new DateRange(now.AddMinutes(12), now.AddMinutes(20)),
                new DateRange(now.AddMinutes(22), now.AddMinutes(30)));
            var result = c1.Intersection(c2);

            Assert.Empty(result);
        }
Exemple #2
0
        public void Intersection_01()
        {
            var now = DateTime.Now;
            var c1  = new DateRangeCollection(
                new DateRange(now.AddHours(1), now.AddHours(3)),
                new DateRange(now.AddHours(5), now.AddHours(7)));
            var c2 = new DateRangeCollection(
                new DateRange(now.AddHours(6), now.AddHours(11)),
                new DateRange(now.AddHours(13), now.AddHours(15)));
            var result = c1.Intersection(c2);

            Assert.Single(result);
            Assert.Equal(now.AddHours(6), result.First().Start);
            Assert.Equal(now.AddHours(7), result.First().End);
        }
Exemple #3
0
        public void Intersection_05()
        {
            var now = DateTime.Now;
            var c1  = new DateRangeCollection(
                new DateRange(now.AddMinutes(5), now.AddMinutes(50)));
            var c2 = new DateRangeCollection(
                new DateRange(now.AddMinutes(2), now.AddMinutes(10)),
                new DateRange(now.AddMinutes(12), now.AddMinutes(20)));
            var result = c1.Intersection(c2);

            Assert.Equal(2, result.Count);
            Assert.Equal(now.AddMinutes(5), result[0].Start);
            Assert.Equal(now.AddMinutes(10), result[0].End);
            Assert.Equal(now.AddMinutes(12), result[1].Start);
            Assert.Equal(now.AddMinutes(20), result[1].End);
        }
Exemple #4
0
        public void Intersection_02()
        {
            var now = DateTime.Now;
            var c1  = new DateRangeCollection(
                new DateRange(now.AddHours(1), now.AddHours(4)),
                new DateRange(now.AddHours(5), now.AddHours(8)));
            var c2 = new DateRangeCollection(
                new DateRange(now.AddHours(2), now.AddHours(3)),
                new DateRange(now.AddHours(6), now.AddHours(7)));
            var result = c1.Intersection(c2);

            Assert.Equal(2, result.Count);
            Assert.Equal(now.AddHours(2), result[0].Start);
            Assert.Equal(now.AddHours(3), result[0].End);
            Assert.Equal(now.AddHours(6), result[1].Start);
            Assert.Equal(now.AddHours(7), result[1].End);
        }
Exemple #5
0
        public void Intersection_07()
        {
            var now = DateTime.Now;
            var c1  = new DateRangeCollection(
                new DateRange(now.AddMinutes(1), now.AddMinutes(10)));
            var c2 = new DateRangeCollection(
                new DateRange(now.AddMinutes(2), now.AddMinutes(3)),
                new DateRange(now.AddMinutes(4), now.AddMinutes(5)),
                new DateRange(now.AddMinutes(6), now.AddMinutes(7)));
            var result = c2.Intersection(c1);

            Assert.Equal(3, result.Count);
            Assert.Equal(now.AddMinutes(2), result[0].Start);
            Assert.Equal(now.AddMinutes(3), result[0].End);
            Assert.Equal(now.AddMinutes(4), result[1].Start);
            Assert.Equal(now.AddMinutes(5), result[1].End);
            Assert.Equal(now.AddMinutes(6), result[2].Start);
            Assert.Equal(now.AddMinutes(7), result[2].End);
        }