[EventKit] Fix a few issues found with iOS 11 (#2198)

* [EventKit] Obsolete the EKAlarm constructor and update tests.

Apple's documentation says "Use the alarmWithAbsoluteDate: and
alarmWithRelativeOffset: class methods to create an alarm", and additionally
calling the default constructor crashes, so obsolete the constructor and don't
call it from tests either.

* [EventKit] Make EKCalendarItem abstract according to Apple's documentation.

Since EKCalendarItem is an abstract class, tests should obviously not create
instances of it - and in fact it fails:

    [FAIL] CalendarItemTest.NullAllowedTest : Foundation.MonoTouchException : Objective-C exception thrown. Name: NSInvalidArgumentException Reason: +[EKCalendarItem frozenClass]: unrecognized selector sent to class 0x10e02bfa0

* [tests] Remove removed file from xammac tests as well.
This commit is contained in:
Rolf Bjarne Kvinge 2017-06-10 00:50:01 -07:00 коммит произвёл GitHub
Родитель bfaf62623e
Коммит 2c3690fe73
6 изменённых файлов: 12 добавлений и 48 удалений

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

@ -72,6 +72,13 @@ namespace XamCore.EventKit {
get { throw new NotSupportedException (); }
set { throw new NotSupportedException (); }
}
#endif
}
partial class EKAlarm {
#if !XAMCORE_4_0
[Obsolete ("Use the static methods FromDate or FromTimeInterval to create alarms")]
public EKAlarm () {}
#endif
}
}

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

@ -54,6 +54,9 @@ namespace XamCore.EventKit {
[Since (5,0)]
[Mac (10,8, onlyOn64: true)]
[BaseType (typeof (EKObject))]
#if XAMCORE_4_0
[Abstract] // "The EKCalendarItem class is a an abstract superclass ..." from Apple docs.
#endif
interface EKCalendarItem {
#if !MONOMAC
// Never made avaialble on MonoMac
@ -188,6 +191,7 @@ namespace XamCore.EventKit {
[Since (4,0)]
[Mac (10,8, onlyOn64: true)]
[BaseType (typeof (EKObject))]
[DisableDefaultCtor] // Documentation says to use the static methods FromDate/FromTimeInterval to create instances
interface EKAlarm : NSCopying {
[Export ("relativeOffset")]
double RelativeOffset { get; set; }

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

@ -33,7 +33,7 @@ namespace MonoTouchFixtures.EventKit {
[Test]
public void NullAllowedTest ()
{
using (var alarm = new EKAlarm ()) {
using (var alarm = EKAlarm.FromTimeInterval (1234)) {
alarm.AbsoluteDate = null;
alarm.StructuredLocation = null;
}

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

@ -1,43 +0,0 @@
//
// Unit tests for EKCalendarItem
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright 2013 Xamarin Inc. All rights reserved.
//
#if !__TVOS__
using System;
#if XAMCORE_2_0
using Foundation;
using CoreGraphics;
using EventKit;
using ObjCRuntime;
#else
using MonoTouch.CoreGraphics;
using MonoTouch.EventKit;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
using MonoTouch.UIKit;
#endif
using NUnit.Framework;
namespace MonoTouchFixtures.EventKit {
[TestFixture]
[Preserve (AllMembers = true)]
public class CalendarItemTest {
[Test]
public void NullAllowedTest ()
{
using (var item = new EKCalendarItem ()) {
item.Notes = null;
}
}
}
}
#endif // !__TVOS__

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

@ -349,7 +349,6 @@
<Compile Include="MapKit\LocalSearchTest.cs" />
<Compile Include="MapKit\LocalSearchRequestTest.cs" />
<Compile Include="Foundation\CalendarTest.cs" />
<Compile Include="EventKit\CalendarItemTest.cs" />
<Compile Include="EventKit\AlarmTest.cs" />
<Compile Include="CoreGraphics\ContextTest.cs" />
<Compile Include="CoreGraphics\DataConsumerTest.cs" />

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

@ -584,9 +584,6 @@
<Compile Include="..\monotouch-test\EventKit\AlarmTest.cs">
<Link>EventKit\AlarmTest.cs</Link>
</Compile>
<Compile Include="..\monotouch-test\EventKit\CalendarItemTest.cs">
<Link>EventKit\CalendarItemTest.cs</Link>
</Compile>
<Compile Include="..\monotouch-test\EventKit\CalendarTest.cs">
<Link>EventKit\CalendarTest.cs</Link>
</Compile>