Move() public method

public Move ( System.TimeSpan offset ) : void
offset System.TimeSpan
return void
Exemplo n.º 1
0
        public void MoveTest()
        {
            TimeRange timeRangeMoveZero = new TimeRange( start, end );
            timeRangeMoveZero.Move( TimeSpan.Zero );
            Assert.AreEqual( timeRangeMoveZero.Start, start );
            Assert.AreEqual( timeRangeMoveZero.End, end );
            Assert.AreEqual( timeRangeMoveZero.Duration, duration );

            TimeRange timeRangeMoveForward = new TimeRange( start, end );
            TimeSpan forwardOffset = new TimeSpan( 2, 30, 15 );
            timeRangeMoveForward.Move( forwardOffset );
            Assert.AreEqual( timeRangeMoveForward.Start, start.Add( forwardOffset ) );
            Assert.AreEqual( timeRangeMoveForward.End, end.Add( forwardOffset ) );

            TimeRange timeRangeMoveBackward = new TimeRange( start, end );
            TimeSpan backwardOffset = new TimeSpan( -1, 10, 30 );
            timeRangeMoveBackward.Move( backwardOffset );
            Assert.AreEqual( timeRangeMoveBackward.Start, start.Add( backwardOffset ) );
            Assert.AreEqual( timeRangeMoveBackward.End, end.Add( backwardOffset ) );
        }
Exemplo n.º 2
0
        public void IsSamePeriodTest()
        {
            TimeRange timeRange1 = new TimeRange( start, end );
            TimeRange timeRange2 = new TimeRange( start, end );

            Assert.IsTrue( timeRange1.IsSamePeriod( timeRange1 ) );
            Assert.IsTrue( timeRange2.IsSamePeriod( timeRange2 ) );

            Assert.IsTrue( timeRange1.IsSamePeriod( timeRange2 ) );
            Assert.IsTrue( timeRange2.IsSamePeriod( timeRange1 ) );

            Assert.IsFalse( timeRange1.IsSamePeriod( TimeRange.Anytime ) );
            Assert.IsFalse( timeRange2.IsSamePeriod( TimeRange.Anytime ) );

            timeRange1.Move( new TimeSpan( 1 ) );
            Assert.IsFalse( timeRange1.IsSamePeriod( timeRange2 ) );
            Assert.IsFalse( timeRange2.IsSamePeriod( timeRange1 ) );

            timeRange1.Move( new TimeSpan( -1 ) );
            Assert.IsTrue( timeRange1.IsSamePeriod( timeRange2 ) );
            Assert.IsTrue( timeRange2.IsSamePeriod( timeRange1 ) );
        }