Copy() public method

public Copy ( ) : ITimeInterval
return ITimeInterval
Example #1
0
        public void CopyTest()
        {
            TimeInterval readOnlyTimeInterval = new TimeInterval( start, end );
            Assert.AreEqual( readOnlyTimeInterval.Copy( TimeSpan.Zero ), readOnlyTimeInterval );

            TimeInterval timeInterval = new TimeInterval( start, end );
            Assert.AreEqual( timeInterval.Start, start );
            Assert.AreEqual( timeInterval.End, end );

            ITimeInterval noMoveTimeInterval = timeInterval.Copy( TimeSpan.Zero );
            Assert.AreEqual( noMoveTimeInterval.Start, start );
            Assert.AreEqual( noMoveTimeInterval.End, end );
            Assert.AreEqual( noMoveTimeInterval.Duration, duration );

            TimeSpan forwardOffset = new TimeSpan( 2, 30, 15 );
            ITimeInterval forwardTimeInterval = timeInterval.Copy( forwardOffset );
            Assert.AreEqual( forwardTimeInterval.Start, start.Add( forwardOffset ) );
            Assert.AreEqual( forwardTimeInterval.End, end.Add( forwardOffset ) );

            TimeSpan backwardOffset = new TimeSpan( -1, 10, 30 );
            ITimeInterval backwardTimeInterval = timeInterval.Copy( backwardOffset );
            Assert.AreEqual( backwardTimeInterval.Start, start.Add( backwardOffset ) );
            Assert.AreEqual( backwardTimeInterval.End, end.Add( backwardOffset ) );
        }