AddHours() public method

public AddHours ( int hours ) : Hour
hours int
return Hour
Example #1
0
        public void AddHoursTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            DateTime nowHour = new DateTime( now.Year, now.Month, now.Day, now.Hour, 0, 0 );
            Hour hour = new Hour( now, TimeCalendar.New( TimeSpan.Zero, TimeSpan.Zero ) );

            Assert.AreEqual( hour.AddHours( 0 ), hour );

            DateTime previousHour = nowHour.AddHours( -1 );
            Assert.AreEqual( hour.AddHours( -1 ).Year, previousHour.Year );
            Assert.AreEqual( hour.AddHours( -1 ).Month, previousHour.Month );
            Assert.AreEqual( hour.AddHours( -1 ).Day, previousHour.Day );
            Assert.AreEqual( hour.AddHours( -1 ).HourValue, previousHour.Hour );

            DateTime nextHour = nowHour.AddHours( 1 );
            Assert.AreEqual( hour.AddHours( 1 ).Year, nextHour.Year );
            Assert.AreEqual( hour.AddHours( 1 ).Month, nextHour.Month );
            Assert.AreEqual( hour.AddHours( 1 ).Day, nextHour.Day );
            Assert.AreEqual( hour.AddHours( 1 ).HourValue, nextHour.Hour );
        }
Example #2
0
 public void GetPreviousHourTest()
 {
     Hour hour = new Hour();
     Assert.AreEqual( hour.GetPreviousHour(), hour.AddHours( -1 ) );
 }
Example #3
0
 public void GetNextHourTest()
 {
     Hour hour = new Hour();
     Assert.AreEqual( hour.GetNextHour(), hour.AddHours( 1 ) );
 }