public void FirstCalendarHalfyearsTest() { const int startYear = 2004; const YearHalfyear startHalfyear = YearHalfyear.First; const int halfyearCount = 3; Halfyears halfyears = new Halfyears( startYear, startHalfyear, halfyearCount ); Assert.AreEqual( halfyears.YearBaseMonth, YearMonth.January ); Assert.AreEqual( halfyears.HalfyearCount, halfyearCount ); Assert.AreEqual( halfyears.StartHalfyear, startHalfyear ); Assert.AreEqual( halfyears.StartYear, startYear ); Assert.AreEqual( halfyears.EndYear, 2005 ); Assert.AreEqual( halfyears.EndHalfyear, YearHalfyear.First ); Assert.AreEqual( halfyears.GetHalfyears().Count, halfyearCount ); Assert.IsTrue( halfyears.GetHalfyears()[ 0 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.First ) ) ); Assert.IsTrue( halfyears.GetHalfyears()[ 1 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.Second ) ) ); Assert.IsTrue( halfyears.GetHalfyears()[ 2 ].IsSamePeriod( new Halfyear( 2005, YearHalfyear.First ) ) ); }
public void FirstCustomCalendarHalfyearsTest() { TimeCalendar calendar = TimeCalendar.New( YearMonth.October ); const int startYear = 2004; const YearHalfyear startHalfyear = YearHalfyear.First; const int halfyearCount = 3; Halfyears halfyears = new Halfyears( startYear, startHalfyear, halfyearCount, calendar ); Assert.AreEqual( halfyears.YearBaseMonth, YearMonth.October ); Assert.AreEqual( halfyears.HalfyearCount, halfyearCount ); Assert.AreEqual( halfyears.StartHalfyear, startHalfyear ); Assert.AreEqual( halfyears.StartYear, startYear ); Assert.AreEqual( halfyears.EndYear, 2005 ); Assert.AreEqual( halfyears.EndHalfyear, YearHalfyear.First ); Assert.AreEqual( halfyears.GetHalfyears().Count, halfyearCount ); Assert.IsTrue( halfyears.GetHalfyears()[ 0 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.First, calendar ) ) ); Assert.IsTrue( halfyears.GetHalfyears()[ 1 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.Second, calendar ) ) ); Assert.IsTrue( halfyears.GetHalfyears()[ 2 ].IsSamePeriod( new Halfyear( 2005, YearHalfyear.First, calendar ) ) ); }
// ---------------------------------------------------------------------- public static void ShowAll( int periodCount, int startYear, YearHalfyear yearHalfyear, TimeCalendarConfig calendarConfig ) { WriteLine( "Input: count={0}, year={1}, halfyear={2}", periodCount, startYear, yearHalfyear ); WriteLine(); HalfyearTimeRange halfyearTimeRange; if ( periodCount == 1 ) { Halfyear halfyear = new Halfyear( startYear, yearHalfyear, new TimeCalendar( calendarConfig ) ); halfyearTimeRange = halfyear; Halfyear previousHalfyear = halfyear.GetPreviousHalfyear(); Halfyear nextHalfyear = halfyear.GetNextHalfyear(); ShowHalfyear( halfyear ); ShowCompactHalfyear( previousHalfyear, "Previous Halfyear" ); ShowCompactHalfyear( nextHalfyear, "Next Halfyear" ); WriteLine(); } else { Halfyears halfyears = new Halfyears( startYear, yearHalfyear, periodCount, new TimeCalendar( calendarConfig ) ); halfyearTimeRange = halfyears; ShowHalfyears( halfyears ); WriteLine(); foreach ( Halfyear halfyear in halfyears.GetHalfyears() ) { ShowCompactHalfyear( halfyear ); } WriteLine(); } foreach ( Quarter quarter in halfyearTimeRange.GetQuarters() ) { QuarterDemo.ShowCompactQuarter( quarter ); } WriteLine(); foreach ( Month month in halfyearTimeRange.GetMonths() ) { MonthDemo.ShowCompactMonth( month ); } WriteLine(); }
public void SingleHalfyearsTest() { const int startYear = 2004; const YearHalfyear startHalfyear = YearHalfyear.Second; Halfyears halfyears = new Halfyears( startYear, startHalfyear, 1 ); Assert.AreEqual( halfyears.YearBaseMonth, YearMonth.January ); Assert.AreEqual( halfyears.HalfyearCount, 1 ); Assert.AreEqual( halfyears.StartHalfyear, startHalfyear ); Assert.AreEqual( halfyears.StartYear, startYear ); Assert.AreEqual( halfyears.EndYear, startYear ); Assert.AreEqual( halfyears.EndHalfyear, YearHalfyear.Second ); Assert.AreEqual( halfyears.GetHalfyears().Count, 1 ); Assert.IsTrue( halfyears.GetHalfyears()[ 0 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.Second ) ) ); }