ExpandTo() public method

public ExpandTo ( System.DateTime moment ) : void
moment System.DateTime
return void
示例#1
0
        public void ExpandToPeriodTest()
        {
            TimeInterval timeInterval = new TimeInterval( start, end );

            // no expansion
            timeInterval.ExpandTo( new TimeInterval( start.AddMilliseconds( 1 ), end.AddMilliseconds( -1 ) ) );
            Assert.AreEqual( timeInterval.Start, start );
            Assert.AreEqual( timeInterval.End, end );

            // start
            DateTime changedStart = start.AddMinutes( -1 );
            timeInterval.ExpandTo( new TimeInterval( changedStart, end ) );
            Assert.AreEqual( timeInterval.Start, changedStart );
            Assert.AreEqual( timeInterval.End, end );

            // end
            DateTime changedEnd = end.AddMinutes( 1 );
            timeInterval.ExpandTo( new TimeInterval( changedStart, changedEnd ) );
            Assert.AreEqual( timeInterval.Start, changedStart );
            Assert.AreEqual( timeInterval.End, changedEnd );

            // start/end
            changedStart = changedStart.AddMinutes( -1 );
            changedEnd = changedEnd.AddMinutes( 1 );
            timeInterval.ExpandTo( new TimeInterval( changedStart, changedEnd ) );
            Assert.AreEqual( timeInterval.Start, changedStart );
            Assert.AreEqual( timeInterval.End, changedEnd );
        }
示例#2
0
        public void ExpandToDateTimeTest()
        {
            TimeInterval timeInterval = new TimeInterval( start, end );

            // start
            timeInterval.ExpandTo( start.AddMilliseconds( 1 ) );
            Assert.AreEqual( timeInterval.Start, start );
            timeInterval.ExpandTo( start.AddMinutes( -1 ) );
            Assert.AreEqual( timeInterval.Start, start.AddMinutes( -1 ) );

            // end
            timeInterval.ExpandTo( end.AddMilliseconds( -1 ) );
            Assert.AreEqual( timeInterval.End, end );
            timeInterval.ExpandTo( end.AddMinutes( 1 ) );
            Assert.AreEqual( timeInterval.End, end.AddMinutes( 1 ) );
        }