diff options
author | Krzysztof Wicher <mordotymoja@gmail.com> | 2018-03-02 00:13:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-02 00:13:56 +0300 |
commit | 12715c4aac0ed144e36a7ef834a7f349196759de (patch) | |
tree | 4e13030ca18d0830e1d01ebd82925731d9f7f963 /src/System.Globalization.Calendars | |
parent | 388d31759ecd2d07dff1711fae05e4ed03c9de6f (diff) |
Fix Japanese Era calendar tests (#27617)
Diffstat (limited to 'src/System.Globalization.Calendars')
3 files changed, 13 insertions, 3 deletions
diff --git a/src/System.Globalization.Calendars/tests/CalendarHelpers.cs b/src/System.Globalization.Calendars/tests/CalendarHelpers.cs index 3551a4ad03..6f6d6eecc0 100644 --- a/src/System.Globalization.Calendars/tests/CalendarHelpers.cs +++ b/src/System.Globalization.Calendars/tests/CalendarHelpers.cs @@ -344,7 +344,7 @@ namespace System.Globalization.Tests // Day is invalid Assert.Throws<ArgumentOutOfRangeException>(() => calendar.ToDateTime(year, month, -1, hour, minute, second, millisecond, era)); Assert.Throws<ArgumentOutOfRangeException>(() => calendar.ToDateTime(year, month, 0, hour, minute, second, millisecond, era)); - Assert.Throws<ArgumentOutOfRangeException>(() => calendar.ToDateTime(year, month, calendar.GetDaysInMonth(year, month, era) + 1, minute, second, millisecond, era)); + Assert.Throws<ArgumentOutOfRangeException>(() => calendar.ToDateTime(year, month, calendar.GetDaysInMonth(year, month, era) + 1, hour, minute, second, millisecond, era)); // Hour is invalid Assert.Throws<ArgumentOutOfRangeException>(() => calendar.ToDateTime(year, month, day, -1, minute, second, millisecond, era)); diff --git a/src/System.Globalization.Calendars/tests/JapaneseCalendar/JapaneseCalendarEras.cs b/src/System.Globalization.Calendars/tests/JapaneseCalendar/JapaneseCalendarEras.cs index f1d99090fa..18804c16f3 100644 --- a/src/System.Globalization.Calendars/tests/JapaneseCalendar/JapaneseCalendarEras.cs +++ b/src/System.Globalization.Calendars/tests/JapaneseCalendar/JapaneseCalendarEras.cs @@ -11,7 +11,17 @@ namespace System.Globalization.Tests [Fact] public void Eras() { - Assert.Equal(new int[] { 4, 3, 2, 1 }, new JapaneseCalendar().Eras); + int[] eras = new JapaneseCalendar().Eras; + int noOfEras = eras.Length; + + Assert.True(noOfEras >= 4); + + // eras should be [ noOfEras, noOfEras - 1, ..., 1 ] + Assert.Equal(noOfEras, eras[0]); + for (int i = 0; i < noOfEras; i++) + { + Assert.Equal(noOfEras - i, eras[i]); + } } } } diff --git a/src/System.Globalization.Calendars/tests/Misc/MiscCalendars.cs b/src/System.Globalization.Calendars/tests/Misc/MiscCalendars.cs index 1db11ee247..ba37f53920 100644 --- a/src/System.Globalization.Calendars/tests/Misc/MiscCalendars.cs +++ b/src/System.Globalization.Calendars/tests/Misc/MiscCalendars.cs @@ -40,7 +40,7 @@ namespace System.Globalization.Tests public static void JapaneseTest() { JapaneseCalendar jCal = new JapaneseCalendar(); - DateTime dTest = jCal.ToDateTime(1, 1, 8, 0, 0, 0, 0); + DateTime dTest = jCal.ToDateTime(1, 1, 8, 0, 0, 0, 0, 4); Assert.Equal(dTest, new DateTime(1989, 1, 8)); } } |