Inheritance: WeekTimeRange
示例#1
0
        public void SingleWeeksTest()
        {
            const int startYear = 2004;
            const int startWeek = 22;
            Weeks weeks = new Weeks( startYear, startWeek, 1 );

            Assert.AreEqual( weeks.Year, startYear );
            Assert.AreEqual( weeks.WeekCount, 1 );
            Assert.AreEqual( weeks.StartWeek, startWeek );
            Assert.AreEqual( weeks.EndWeek, startWeek );
            Assert.AreEqual( weeks.GetWeeks().Count, 1 );
            Assert.IsTrue( weeks.GetWeeks()[ 0 ].IsSamePeriod( new Week( 2004, 22 ) ) );
        }
示例#2
0
        public void MultiWeekTest()
        {
            const int startYear = 2004;
            const int startWeek = 22;
            const int weekCount = 4;
            Weeks weeks = new Weeks( startYear, startWeek, weekCount );

            Assert.AreEqual( weeks.Year, startYear );
            Assert.AreEqual( weeks.WeekCount, weekCount );
            Assert.AreEqual( weeks.StartWeek, startWeek );
            Assert.AreEqual( weeks.EndWeek, startWeek + weekCount - 1 );
            Assert.AreEqual( weeks.GetWeeks().Count, weekCount );
            Assert.IsTrue( weeks.GetWeeks()[ 0 ].IsSamePeriod( new Week( 2004, 22 ) ) );
        }
示例#3
0
        public void CalendarWeeksTest()
        {
            const int startYear = 2004;
            const int startWeek = 22;
            const int weekCount = 5;
            Weeks weeks = new Weeks( startYear, startWeek, weekCount );

            Assert.AreEqual( weeks.Year, startYear );
            Assert.AreEqual( weeks.WeekCount, weekCount );
            Assert.AreEqual( weeks.StartWeek, startWeek );
            Assert.AreEqual( weeks.EndWeek, startWeek + weekCount - 1 );
            Assert.AreEqual( weeks.GetWeeks().Count, weekCount );
            Assert.IsTrue( weeks.GetWeeks()[ 0 ].IsSamePeriod( new Week( 2004, 22 ) ) );
            Assert.IsTrue( weeks.GetWeeks()[ 1 ].IsSamePeriod( new Week( 2004, 23 ) ) );
            Assert.IsTrue( weeks.GetWeeks()[ 2 ].IsSamePeriod( new Week( 2004, 24 ) ) );
            Assert.IsTrue( weeks.GetWeeks()[ 3 ].IsSamePeriod( new Week( 2004, 25 ) ) );
            Assert.IsTrue( weeks.GetWeeks()[ 4 ].IsSamePeriod( new Week( 2004, 26 ) ) );
        }
示例#4
0
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int year, int weekOfYear, TimeCalendarConfig calendarConfig )
        {
            WriteLine( "Input: year={0}, week={1}", year, weekOfYear );
            WriteLine();

            WeekTimeRange weekTimeRange;
            if ( periodCount == 1 )
            {
                Week week = new Week( year, weekOfYear, new TimeCalendar( calendarConfig ) );
                weekTimeRange = week;

                Week previousWeek = week.GetPreviousWeek();
                Week nextWeek = week.GetNextWeek();

                ShowWeek( week );
                ShowCompactWeek( previousWeek, "Previous Week" );
                ShowCompactWeek( nextWeek, "Next Week" );
                WriteLine();
            }
            else
            {
                Weeks weeks = new Weeks( year, weekOfYear, periodCount, new TimeCalendar( calendarConfig ) );
                weekTimeRange = weeks;

                ShowWeeks( weeks );
                WriteLine();

                foreach ( Week week in weeks.GetWeeks() )
                {
                    ShowCompactWeek( week );
                }
                WriteLine();
            }

            foreach ( Day day in weekTimeRange.GetDays() )
            {
                DayDemo.ShowCompactDay( day );
            }
            WriteLine();
        }
示例#5
0
 // ----------------------------------------------------------------------
 public static void ShowWeeks( Weeks weeks, string caption = "Weeks" )
 {
     WriteLine( "{0}: {1}", caption, weeks );
     WriteIndentLine( "YearWeek: {0}", Format( weeks.Start ) );
     WriteIndentLine( "FirstDayStart: {0}", Format( weeks.FirstDayStart ) );
     WriteIndentLine( "LastDayStart: {0}", Format( weeks.LastDayStart ) );
     WriteIndentLine( "StartWeek: {0}", weeks.StartWeek );
     WriteIndentLine( "StartWeekOfYearName: {0}", weeks.StartWeekOfYearName );
     WriteIndentLine( "EndWeek: {0}", weeks.EndWeek );
     WriteIndentLine( "EndWeekOfYearName: {0}", weeks.EndWeekOfYearName );
     WriteLine();
 }
示例#6
0
 // ----------------------------------------------------------------------
 public static void ShowCompactWeeks( Weeks weeks, string caption = "Weeks" )
 {
     WriteLine( "{0}: {1}", caption, weeks );
 }