public void SingleHoursTest() { const int startYear = 2004; const int startMonth = 2; const int startDay = 22; const int startHour = 17; Hours hours = new Hours( startYear, startMonth, startDay, startHour, 1 ); Assert.AreEqual( hours.HourCount, 1 ); Assert.AreEqual( hours.StartYear, startYear ); Assert.AreEqual( hours.StartMonth, startMonth ); Assert.AreEqual( hours.StartDay, startDay ); Assert.AreEqual( hours.StartHour, startHour ); Assert.AreEqual( hours.EndYear, 2004 ); Assert.AreEqual( hours.EndMonth, 2 ); Assert.AreEqual( hours.EndDay, startDay ); Assert.AreEqual( hours.EndHour, startHour + 1 ); Assert.AreEqual( hours.GetHours().Count, 1 ); Assert.IsTrue( hours.GetHours()[ 0 ].IsSamePeriod( new Hour( 2004, 2, 22, 17 ) ) ); }
public void CalendarHoursTest() { const int startYear = 2004; const int startMonth = 2; const int startDay = 11; const int startHour = 22; const int hourCount = 4; Hours hours = new Hours( startYear, startMonth, startDay, startHour, hourCount ); Assert.AreEqual( hours.HourCount, hourCount ); Assert.AreEqual( hours.StartYear, startYear ); Assert.AreEqual( hours.StartMonth, startMonth ); Assert.AreEqual( hours.StartDay, startDay ); Assert.AreEqual( hours.StartHour, startHour ); Assert.AreEqual( hours.EndYear, 2004 ); Assert.AreEqual( hours.EndMonth, 2 ); Assert.AreEqual( hours.EndDay, startDay + 1 ); Assert.AreEqual( hours.EndHour, 2 ); Assert.AreEqual( hours.GetHours().Count, hourCount ); Assert.IsTrue( hours.GetHours()[ 0 ].IsSamePeriod( new Hour( 2004, 2, 11, 22 ) ) ); Assert.IsTrue( hours.GetHours()[ 1 ].IsSamePeriod( new Hour( 2004, 2, 11, 23 ) ) ); Assert.IsTrue( hours.GetHours()[ 2 ].IsSamePeriod( new Hour( 2004, 2, 12, 0 ) ) ); Assert.IsTrue( hours.GetHours()[ 3 ].IsSamePeriod( new Hour( 2004, 2, 12, 1 ) ) ); }
// ---------------------------------------------------------------------- public static void ShowAll( int periodCount, int year, YearMonth month, int day, int hourValue ) { WriteLine( "Input: count={0}, year={1}, month={2}, day={3}, hour={4}", periodCount, year, month, day, hourValue ); WriteLine(); HourTimeRange hourTimeRange; if ( periodCount == 1 ) { Hour hour = new Hour( year, (int)month, day, hourValue ); hourTimeRange = hour; Hour previousHour = hour.GetPreviousHour(); Hour nextHour = hour.GetNextHour(); ShowHour( hour ); ShowCompactHour( previousHour, "Previous Hour" ); ShowCompactHour( nextHour, "Next Hour" ); WriteLine(); } else { Hours hours = new Hours( year, (int)month, day, hourValue, periodCount ); hourTimeRange = hours; ShowHours( hours ); WriteLine(); foreach ( Hour hour in hours.GetHours() ) { ShowCompactHour( hour ); } WriteLine(); } foreach ( Minute minute in hourTimeRange.GetMinutes() ) { MinuteDemo.ShowCompactMinute( minute ); } WriteLine(); }