public void WeekOfYearCalendarTest() { var period = new TimeRange(new DateTime(2007, 12, 31), new DateTime(2009, 12, 31)); var moments = TimeTool.ForEachDays(period) #if !SILVERLIGHT .AsParallel() .AsOrdered() #endif .Select(p => p.Start); foreach (var culture in CultureTestData.Default) { var rule = WeekTool.GetWeekOfYearRuleKind(culture.DateTimeFormat.CalendarWeekRule, culture.DateTimeFormat.FirstDayOfWeek); if (rule == WeekOfYearRuleKind.Iso8601) { continue; } foreach (var moment in moments) { var calendarWeekOfYear = culture.Calendar.GetWeekOfYear(moment, culture.DateTimeFormat.CalendarWeekRule, culture.DateTimeFormat.FirstDayOfWeek); var yearAndWeek = TimeTool.GetWeekOfYear(moment, culture, WeekOfYearRuleKind.Calendar); Assert.AreEqual(calendarWeekOfYear, yearAndWeek.Week, "calendar WeekOfYear=[{0}], yearAndWeek=[{1}], culture=[{2}], momnent=[{3}], weekRule=[{4}], FirstDayOfWeek=[{5}]", calendarWeekOfYear, yearAndWeek, culture, moment, culture.DateTimeFormat.CalendarWeekRule, culture.DateTimeFormat.FirstDayOfWeek); } } }