Example #1
0
        public void ExpandToPeriodTest()
        {
            TimeRange timeRange = new TimeRange(_start, _end);

            // no expansion
            timeRange.ExpandTo(new TimeRange(_start.AddMilliseconds(1), _end.AddMilliseconds(-1)));
            timeRange.Start.Should().Be(_start);
            timeRange.End.Should().Be(_end);

            // start
            var changedStart = _start.AddMinutes(-1);

            timeRange.ExpandTo(new TimeRange(changedStart, _end));
            timeRange.Start.Should().Be(changedStart);
            timeRange.End.Should().Be(_end);

            // end
            var changedEnd = _end.AddMinutes(1);

            timeRange.ExpandTo(new TimeRange(changedStart, changedEnd));
            timeRange.Start.Should().Be(changedStart);
            timeRange.End.Should().Be(changedEnd);

            // start/end
            changedStart = changedStart.AddMinutes(-1);
            changedEnd   = changedEnd.AddMinutes(1);
            timeRange.ExpandTo(new TimeRange(changedStart, changedEnd));
            timeRange.Start.Should().Be(changedStart);
            timeRange.End.Should().Be(changedEnd);
        }
        public void ExpandToPeriodTest()
        {
            TimeRange timeRange = new TimeRange(start, end);

            // no expansion
            timeRange.ExpandTo(new TimeRange(start.AddMilliseconds(1), end.AddMilliseconds(-1)));
            Assert.Equal(timeRange.Start, start);
            Assert.Equal(timeRange.End, end);

            // start
            DateTime changedStart = start.AddMinutes(-1);

            timeRange.ExpandTo(new TimeRange(changedStart, end));
            Assert.Equal(timeRange.Start, changedStart);
            Assert.Equal(timeRange.End, end);

            // end
            DateTime changedEnd = end.AddMinutes(1);

            timeRange.ExpandTo(new TimeRange(changedStart, changedEnd));
            Assert.Equal(timeRange.Start, changedStart);
            Assert.Equal(timeRange.End, changedEnd);

            // start/end
            changedStart = changedStart.AddMinutes(-1);
            changedEnd   = changedEnd.AddMinutes(1);
            timeRange.ExpandTo(new TimeRange(changedStart, changedEnd));
            Assert.Equal(timeRange.Start, changedStart);
            Assert.Equal(timeRange.End, changedEnd);
        }         // ExpandToPeriodTest
        public void ExpandToDateTimeTest()
        {
            TimeRange timeRange = new TimeRange(start, end);

            // start
            timeRange.ExpandTo(start.AddMilliseconds(1));
            Assert.Equal(timeRange.Start, start);
            timeRange.ExpandTo(start.AddMinutes(-1));
            Assert.Equal(timeRange.Start, start.AddMinutes(-1));

            // end
            timeRange.ExpandTo(end.AddMilliseconds(-1));
            Assert.Equal(timeRange.End, end);
            timeRange.ExpandTo(end.AddMinutes(1));
            Assert.Equal(timeRange.End, end.AddMinutes(1));
        }         // ExpandToDateTimeTest
Example #4
0
        public void ExpandToDateTimeTest()
        {
            var timeRange = new TimeRange(_start, _end);

            // start
            timeRange.ExpandTo(_start.AddMilliseconds(1));
            timeRange.Start.Should().Be(_start);

            timeRange.ExpandTo(_start.AddMinutes(-1));
            timeRange.Start.Should().Be(_start.AddMinutes(-1));

            // end
            timeRange.ExpandTo(_end.AddMilliseconds(-1));
            timeRange.End.Should().Be(_end);

            timeRange.ExpandTo(_end.AddMinutes(1));
            timeRange.End.Should().Be(_end.AddMinutes(1));
        }
Example #5
0
        public void ExpandToPeriodTest() {
            TimeRange timeRange = new TimeRange(_start, _end);

            // no expansion
            timeRange.ExpandTo(new TimeRange(_start.AddMilliseconds(1), _end.AddMilliseconds(-1)));
            timeRange.Start.Should().Be(_start);
            timeRange.End.Should().Be(_end);

            // start
            var changedStart = _start.AddMinutes(-1);
            timeRange.ExpandTo(new TimeRange(changedStart, _end));
            timeRange.Start.Should().Be(changedStart);
            timeRange.End.Should().Be(_end);

            // end
            var changedEnd = _end.AddMinutes(1);
            timeRange.ExpandTo(new TimeRange(changedStart, changedEnd));
            timeRange.Start.Should().Be(changedStart);
            timeRange.End.Should().Be(changedEnd);

            // start/end
            changedStart = changedStart.AddMinutes(-1);
            changedEnd = changedEnd.AddMinutes(1);
            timeRange.ExpandTo(new TimeRange(changedStart, changedEnd));
            timeRange.Start.Should().Be(changedStart);
            timeRange.End.Should().Be(changedEnd);
        }
Example #6
0
        public void ExpandToDateTimeTest() {
            var timeRange = new TimeRange(_start, _end);

            // start
            timeRange.ExpandTo(_start.AddMilliseconds(1));
            timeRange.Start.Should().Be(_start);

            timeRange.ExpandTo(_start.AddMinutes(-1));
            timeRange.Start.Should().Be(_start.AddMinutes(-1));

            // end
            timeRange.ExpandTo(_end.AddMilliseconds(-1));
            timeRange.End.Should().Be(_end);

            timeRange.ExpandTo(_end.AddMinutes(1));
            timeRange.End.Should().Be(_end.AddMinutes(1));
        }