public void GetYearInfo_should_be_callable_indirectly() { using (new IndirectionsContext()) { // Arrange PJapaneseLunisolarCalendar.GetYearInfoInt32Int32().Body = (@this, lunarYear, index) => 41; // Act var calendar = new JapaneseLunisolarCalendar(); var actual = calendar.GetLeapMonth(26, calendar.Eras[0]); // Assert // Before setting indirection: 平成 26 年 閏 9 Assert.AreEqual(42, actual); } }
public void CalEraInfo_should_be_callable_indirectly() { using (new IndirectionsContext()) { // Arrange var japaneseLunisolarCalendar_get_CalEraInfo = default(MethodInfo); var expected = default(Array); MakeCalEraInfoTestData(out japaneseLunisolarCalendar_get_CalEraInfo, out expected); PJapaneseLunisolarCalendar.CalEraInfoGet().Body = args => expected; // Act var calendar = new JapaneseLunisolarCalendar(); var actual = japaneseLunisolarCalendar_get_CalEraInfo.Invoke(calendar, null) as IEnumerable; // Assert CollectionAssert.AreEqual(expected, actual); } }
public static void JapaneseLunisolarTest() { JapaneseLunisolarCalendar cal = new JapaneseLunisolarCalendar(); Assert.True(cal.Eras.Length >= 2); }
/// <summary> /// GetCalendar returns a .NET Calendar equivalent to a CLDR Calendar /// </summary> /// <param name="calendar">A CLDR Calendar</param> /// <returns>A .NET Calendar</returns> private static System.Globalization.Calendar GetCalendar(Types.Calendar calendar) { System.Globalization.Calendar dotNetCalendar = null; if (string.Compare(calendar.Id, "gregorian", StringComparison.InvariantCulture) == 0 && calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.SolarCalendar) { dotNetCalendar = new GregorianCalendar(); } else if (string.Compare(calendar.Id, "japanese", StringComparison.InvariantCulture) == 0) { if (calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.SolarCalendar) { dotNetCalendar = new JapaneseCalendar(); } else if (calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.LunisolarCalendar) { dotNetCalendar = new JapaneseLunisolarCalendar(); } } else if (string.Compare(calendar.Id, "islamic-civil", StringComparison.InvariantCulture) == 0 && calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.LunisolarCalendar) { dotNetCalendar = new HijriCalendar(); } else if (string.Compare(calendar.Id, "islamic", StringComparison.InvariantCulture) == 0 && calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.LunisolarCalendar) { dotNetCalendar = new HijriCalendar(); } else if (string.Compare(calendar.Id, "chinese", StringComparison.InvariantCulture) == 0 && calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.LunisolarCalendar) { dotNetCalendar = new ChineseLunisolarCalendar(); } else if (string.Compare(calendar.Id, "hebrew", StringComparison.InvariantCulture) == 0 && calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.LunisolarCalendar) { dotNetCalendar = new HebrewCalendar(); } else if (string.Compare(calendar.Id, "buddhist", StringComparison.InvariantCulture) == 0 && calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.SolarCalendar) { dotNetCalendar = new ThaiBuddhistCalendar(); } else if (string.Compare(calendar.Id, "coptic", StringComparison.InvariantCulture) == 0) { return null; } else if (string.Compare(calendar.Id, "persian", StringComparison.InvariantCulture) == 0 && calendar.CalendarType.CalendarAlgorithmType == CalendarAlgorithmType.SolarCalendar) { return new PersianCalendar(); } else if (string.Compare(calendar.Id, "ethiopic", StringComparison.InvariantCulture) == 0) { return null; } else if (string.Compare(calendar.Id, "indian", StringComparison.InvariantCulture) == 0) { return null; } else if (string.Compare(calendar.Id, "roc", StringComparison.InvariantCulture) == 0) { return null; } return dotNetCalendar; }
protected void SetUp() { gcal = new GregorianCalendar(); jucal = new JulianCalendar(); hical = new HijriCalendar(); hecal = new HebrewCalendar(); jacal = new JapaneseCalendar(); tacal = new TaiwanCalendar(); kcal = new KoreanCalendar(); tbcal = new ThaiBuddhistCalendar(); acal = new Calendar[] { gcal, jucal, hical, hecal, jacal, tacal, kcal, tbcal}; #if NET_2_0 clcal = new ChineseLunisolarCalendar (); tlcal = new TaiwanLunisolarCalendar (); jlcal = new JapaneseLunisolarCalendar (); klcal = new KoreanLunisolarCalendar (); #endif }
public void GetYearInfo_should_be_callable_indirectly_against_only_specified_instance() { using (new IndirectionsContext()) { // Arrange var calendar = new JapaneseLunisolarCalendar(); var calendarProxy = new PProxyJapaneseLunisolarCalendar(); calendarProxy.GetEraDateTime().Body = (@this, time) => calendar.Eras[0]; calendarProxy.GetGregorianYearInt32Int32().Body = (@this, year, era) => 2000; calendarProxy.GetYearInfoInt32Int32().Body = (@this, lunarYear, index) => 41; var calendar_sut = (JapaneseLunisolarCalendar)calendarProxy; // Act var actual = calendar_sut.GetLeapMonth(26, calendar.Eras[0]); // Assert Assert.AreEqual(42, actual); Assert.AreNotEqual(calendar.GetLeapMonth(26, calendar.Eras[0]), actual); } }
public void CalEraInfo_should_be_callable_indirectly_against_only_specified_instance() { using (new IndirectionsContext()) { // Arrange var calendar = new JapaneseLunisolarCalendar(); var calendarProxy = new PProxyJapaneseLunisolarCalendar(); var japaneseLunisolarCalendar_get_CalEraInfo = default(MethodInfo); var expected = default(Array); MakeCalEraInfoTestData(out japaneseLunisolarCalendar_get_CalEraInfo, out expected); calendarProxy.CalEraInfoGet().Body = args => expected; var calendar_sut = (JapaneseLunisolarCalendar)calendarProxy; // Act var actual = japaneseLunisolarCalendar_get_CalEraInfo.Invoke(calendar_sut, null) as IEnumerable; // Assert CollectionAssert.AreEqual(expected, actual); CollectionAssert.AreNotEqual(japaneseLunisolarCalendar_get_CalEraInfo.Invoke(calendar, null) as IEnumerable, actual); } }
public DateTimeFormatter(string dateTimePattern, string calendarName, string amDesignator, string pmDesignator) { Calendar calendar = null; switch (calendarName) { case "ChineseLunisolarCalendar": calendar = new ChineseLunisolarCalendar(); break; case "GregorianCalendar": calendar = new GregorianCalendar(); break; case "HebrewCalendar": calendar = new HebrewCalendar(); break; case "HijriCalendar": calendar = new HijriCalendar(); break; case "JapaneseCalendar": calendar = new JapaneseCalendar(); break; case "JapaneseLunisolarCalendar": calendar = new JapaneseLunisolarCalendar(); break; case "JulianCalendar": calendar = new JulianCalendar(); break; case "KoreanCalendar": calendar = new KoreanCalendar(); break; case "KoreanLunisolarCalendar": calendar = new KoreanLunisolarCalendar(); break; case "PersianCalendar": calendar = new PersianCalendar(); break; case "TaiwanCalendar": calendar = new TaiwanCalendar(); break; case "TaiwanLunisolarCalendar": calendar = new TaiwanLunisolarCalendar(); break; case "ThaiBuddhistCalendar": calendar = new ThaiBuddhistCalendar(); break; case "UmAlQuraCalendar": calendar = new UmAlQuraCalendar(); break; } Initialize(dateTimePattern, calendar, amDesignator, pmDesignator); }