public void WeekDateFromComponentsOutOfRangeTest() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => { new WeekDate(0, 1, 1); }); Assert.ThrowsException <ArgumentOutOfRangeException>(() => { new WeekDate(10000, 1, 1); }); Assert.ThrowsException <ArgumentOutOfRangeException>(() => { new WeekDate(2000, 0, 1); }); Assert.ThrowsException <ArgumentOutOfRangeException>(() => { new WeekDate(2000, WeekDate.GetWeeksInYear(2000) + 1, 1); }); Assert.ThrowsException <ArgumentOutOfRangeException>(() => { new WeekDate(2000, 1, 0); }); Assert.ThrowsException <ArgumentOutOfRangeException>(() => { new WeekDate(2000, 1, 8); }); }
public void GetYearTest() { foreach (var convertedDate in DateTimesByWeekDates) { Assert.AreEqual( convertedDate.Key.Year, WeekDate.GetYear(convertedDate.Value)); } }
public void GetWeekdayNumberTest() { foreach (var dayOfWeek in DaysOfWeek) { Assert.AreEqual( dayOfWeek.Key, WeekDate.GetWeekdayNumber(dayOfWeek.Value)); } }
public void GetWeeksInYearTest() { for (int year = 1; year <= CycleLength; year++) { Assert.AreEqual( LongYears.Contains(year) ? 53 : 52, WeekDate.GetWeeksInYear(year), $"{year}"); } }
public void ParseExactFormatSpecifiersTest() { foreach (KeyValuePair <KeyValuePair <string, string>, WeekDate> weekDateByFormat in WeekDatesByFormats) { Assert.AreEqual( weekDateByFormat.Value, WeekDate.ParseExact(weekDateByFormat.Key.Value, weekDateByFormat.Key.Key), $"Format: {weekDateByFormat.Key.Key}; String: {weekDateByFormat.Key.Value}"); Assert.AreEqual( weekDateByFormat.Value, WeekDate.ParseExact(weekDateByFormat.Key.Value, WeekDate.Formats[weekDateByFormat.Key.Key]), $"Format: {WeekDate.Formats[weekDateByFormat.Key.Key]}; String: {weekDateByFormat.Key.Value}"); } }
public void ParseExactInvalidFormatStringTest() { WeekDate.ParseExact("2019-W10-1", DateTimeFormatInfo.InvariantInfo.FullDateTimePattern); }
public void ParseExactEmptyFormatStringTest() { WeekDate.ParseExact("2019-W10-1", string.Empty); }
public void ParseExactEmptySourceStringTest() { WeekDate.ParseExact(string.Empty, "d"); }
public void ParseExactNullFormatStringTest() { WeekDate.ParseExact("2019-W10-1", null); }
public void ParseExactNullSourceStringTest() { WeekDate.ParseExact(null, "d"); }
public void GetWeekdayNumberArgumentOutOfRangeTest() { WeekDate.GetWeekdayNumber((DayOfWeek)8); }
public void GetWeeksInYearMoreThanMaximalTest() { WeekDate.GetWeeksInYear(10000); }
public void GetWeeksInYearLessThanMinimalTest() { WeekDate.GetWeeksInYear(-1); }