Beispiel #1
0
        public void GetWeekOfYearTest()
        {
            DateTime        now      = ClockProxy.Clock.Now;
            CultureTestData cultures = new CultureTestData();

            foreach (CultureInfo culture in cultures)
            {
                foreach (CalendarWeekRule weekRule in Enum.GetValues(typeof(CalendarWeekRule)))
                {
                    culture.DateTimeFormat.CalendarWeekRule = weekRule;

                    int year;
                    int weekOfYear;

                    // calendar week
                    TimeCalendar timeCalendar = TimeCalendar.New(culture);
                    TimeTool.GetWeekOfYear(now, culture, weekRule, culture.DateTimeFormat.FirstDayOfWeek, YearWeekType.Calendar,
                                           out year, out weekOfYear);
                    Assert.Equal <int>(timeCalendar.GetWeekOfYear(now), weekOfYear);

                    // iso 8601 calendar week
                    TimeCalendar timeCalendarIso8601 = TimeCalendar.New(culture, YearMonth.January, YearWeekType.Iso8601);
                    TimeTool.GetWeekOfYear(now, culture, weekRule, culture.DateTimeFormat.FirstDayOfWeek, YearWeekType.Iso8601,
                                           out year, out weekOfYear);
                    Assert.Equal <int>(timeCalendarIso8601.GetWeekOfYear(now), weekOfYear);
                }
            }
        }         // GetWeekOfYearTest