2016-05-26 16:06:52 +03:00
|
|
|
//
|
|
|
|
// Unit tests for ABSource
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Sebastien Pouliot <sebastien@xamarin.com>
|
|
|
|
//
|
|
|
|
// Copyright 2012-2013 Xamarin Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2021-04-07 07:04:48 +03:00
|
|
|
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC && !__MACCATALYST__
|
2016-05-26 16:06:52 +03:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using Foundation;
|
|
|
|
using UIKit;
|
|
|
|
using AddressBook;
|
|
|
|
using ObjCRuntime;
|
|
|
|
using NUnit.Framework;
|
2021-11-15 10:06:36 +03:00
|
|
|
using Xamarin.Utils;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
|
|
|
namespace MonoTouchFixtures.AddressBook {
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
[Preserve (AllMembers = true)]
|
|
|
|
public class SourceTest {
|
|
|
|
|
2020-12-15 15:16:07 +03:00
|
|
|
[SetUp]
|
|
|
|
public void Setup ()
|
|
|
|
{
|
2021-01-21 15:50:10 +03:00
|
|
|
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
|
2021-11-15 10:06:36 +03:00
|
|
|
TestRuntime.AssertSystemVersion (ApplePlatform.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
|
2020-12-15 15:16:07 +03:00
|
|
|
}
|
|
|
|
|
2016-05-26 16:06:52 +03:00
|
|
|
[Test]
|
|
|
|
public void Default ()
|
|
|
|
{
|
|
|
|
if (Runtime.Arch != Arch.SIMULATOR)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// we assume the simulator defaults (e.g. after a reset)
|
|
|
|
ABSource source = new ABAddressBook ().GetDefaultSource ();
|
|
|
|
Assert.Null (source.Name, "Name");
|
|
|
|
Assert.That (source.SourceType, Is.EqualTo (ABSourceType.Local), "SourceType");
|
|
|
|
|
|
|
|
// ABRecord
|
|
|
|
// some bots returns -1 (invalid) and I get 0 after a reset (maybe permission related?)
|
|
|
|
Assert.That (source.Id, Is.LessThanOrEqualTo (0), "Id");
|
2017-11-07 22:48:16 +03:00
|
|
|
// iOS [9,11.2[ returned ABRecordType.Person, otherwise ABRecordType.Source
|
|
|
|
Assert.That (source.Type, Is.Not.EqualTo (ABRecordType.Group), "Type");
|
2016-05-26 16:06:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-07 07:04:48 +03:00
|
|
|
#endif // !__TVOS__ && !__WATCHOS__ && !__MACCATALYST__
|