[Test, Timeout(300000)] // Can take a long time under NCrunch. public void BclThroughHistory_Scriptural() { Calendar bcl = new HebrewCalendar(); var noda = CalendarSystem.HebrewScriptural; // The min supported date/time starts part way through the year var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1; // The max supported date/time ends part way through the year var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1; // Can't use BclEquivalenceHelper for this one, because of the month conversions. for (int year = minYear; year <= maxYear; year++) { int months = bcl.GetMonthsInYear(year); Assert.AreEqual(months, noda.GetMonthsInYear(year)); for (int civilMonth = 1; civilMonth <= months; civilMonth++) { int scripturalMonth = HebrewMonthConverter.CivilToScriptural(year, civilMonth); Assert.AreEqual(bcl.GetDaysInMonth(year, civilMonth), noda.GetDaysInMonth(year, scripturalMonth), "Year: {0}; Month: {1} (civil)", year, civilMonth); for (int day = 1; day < bcl.GetDaysInMonth(year, civilMonth); day++) { DateTime bclDate = new DateTime(year, civilMonth, day, bcl); LocalDate nodaDate = new LocalDate(year, scripturalMonth, day, noda); Assert.AreEqual(bclDate, nodaDate.AtMidnight().ToDateTimeUnspecified(), "{0}-{1}-{2}", year, scripturalMonth, day); Assert.AreEqual(nodaDate, LocalDateTime.FromDateTime(bclDate, noda).Date); Assert.AreEqual(year, nodaDate.Year); Assert.AreEqual(scripturalMonth, nodaDate.Month); Assert.AreEqual(day, nodaDate.Day); } } } }
public void DaysInMonth() { var bcl = new HebrewCalendar(); // Not all months in the min/max years are supported var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1; var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1; for (int year = minYear; year <= maxYear; year++) { int months = bcl.GetMonthsInYear(year); for (int month = 1; month <= months; month++) { int scripturalMonth = HebrewMonthConverter.CivilToScriptural(year, month); int bclDays = bcl.GetDaysInMonth(year, month); int nodaDays = HebrewScripturalCalculator.DaysInMonth(year, scripturalMonth); Assert.AreEqual(bclDays, nodaDays); } } }
[TestCase(13, 7)] // Adar II public void LeapYear(int scriptural, int civil) { Assert.AreEqual(scriptural, HebrewMonthConverter.CivilToScriptural(SampleLeapYear, civil)); Assert.AreEqual(civil, HebrewMonthConverter.ScripturalToCivil(SampleLeapYear, scriptural)); }