private static string CalendarToString(Calendar calendar) { var algorithmType = calendar.AlgorithmType.ToString().Replace("Calendar", ""); if (calendar.GetType() == typeof(GregorianCalendar)) { var gregorianCalendar = (GregorianCalendar)calendar; return string.Format("Gregorian-{0} ({1})", gregorianCalendar.CalendarType, algorithmType); } return string.Format("{0} ({1})", calendar.ToString().Replace("System.Globalization.", "").Replace("Calendar", ""), algorithmType); }
public void DateSelectedEvent() { string testString = null; Calendar calendar = new Calendar(); calendar.SelectionMode = CalendarSelectionMode.SingleDate; calendar.SelectedDatesChanged += new EventHandler<SelectionChangedEventArgs>(delegate { testString = "Handled!"; }); DateTime value = new DateTime(2000, 10, 10); calendar.SelectedDate = value; Assert.AreEqual(testString, "Handled!"); Assert.AreEqual(calendar.ToString(), value.ToString()); }