public void CompareTo_SameCalendar() { YearMonth yearMonth1 = new YearMonth(2011, 1); YearMonth yearMonth2 = new YearMonth(2011, 1); YearMonth date3 = new YearMonth(2011, 2); Assert.That(yearMonth1.CompareTo(yearMonth2), Is.EqualTo(0)); Assert.That(yearMonth1.CompareTo(date3), Is.LessThan(0)); Assert.That(date3.CompareTo(yearMonth2), Is.GreaterThan(0)); }
public void CompareTo_DifferentCalendars_Throws() { CalendarSystem islamic = CalendarSystem.GetIslamicCalendar(IslamicLeapYearPattern.Base15, IslamicEpoch.Astronomical); YearMonth yearMonth1 = new YearMonth(2011, 1); YearMonth yearMonth2 = new YearMonth(1500, 1, islamic); Assert.Throws <ArgumentException>(() => yearMonth1.CompareTo(yearMonth2)); Assert.Throws <ArgumentException>(() => ((IComparable)yearMonth1).CompareTo(yearMonth2)); }
public int CompareTo(FileItem other) { var c = StringComparer.OrdinalIgnoreCase.Compare(Name, other.Name); return((c != 0) ? c : YearMonth.CompareTo(other.YearMonth)); }