[monotouch-test] Make CalendarTest.TestOrdinality location-agnostic. Fixes #xamarin/maccore@2471. (#12192)

Modifying the test to use UTC datetimes instead of local datetimes + specify
the timezone for the NSCalendar to make the results predictable everywhere and
at all times.

Fixes https://github.com/xamarin/maccore/issues/2471.
This commit is contained in:
Rolf Bjarne Kvinge 2021-07-27 07:37:15 +02:00 коммит произвёл GitHub
Родитель 2032f4a09a
Коммит 52ad560f3b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -420,9 +420,10 @@ namespace MonoTouchFixtures.Foundation {
public void TestOrdinality (int year, int month, int day, NSCalendarUnit smaller, NSCalendarUnit larger, int expected)
{
var cal = new NSCalendar (NSCalendarType.Gregorian);
var date = new DateTime (year, month, day, 0, 0, 0, DateTimeKind.Local);
var ordinality = cal.Ordinality (smaller, larger, (NSDate) date);
Assert.AreEqual (ordinality, (nuint) expected);
var date = new DateTime (year, month, day, 0, 0, 0, DateTimeKind.Utc);
var dt = (NSDate) date;
cal.TimeZone = NSTimeZone.FromName ("Europe/Madrid");
Assert.AreEqual ((nuint) expected, cal.Ordinality (smaller, larger, dt), $"Ordinality");
}
[TestCase (2010, 1, 11, NSCalendarUnit.Day, 86400.0)]