[Foundation] Add not bound NSDateComponentUndefined. Fixes 60740 (#3471)

Added the value and provided tests that show the API usage. Value was
inferred from the headers:

NSDateComponentUndefined = NSIntegerMax
This commit is contained in:
Manuel de la Pena 2018-02-13 20:38:24 +01:00 коммит произвёл GitHub
Родитель 1ae3156da1
Коммит 7472c8237d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 41 добавлений и 0 удалений

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

@ -0,0 +1,7 @@
using System;
namespace Foundation {
public partial class NSDateComponents {
public static readonly nint Undefined = nint.MaxValue;
}
}

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

@ -658,6 +658,7 @@ FOUNDATION_CORE_SOURCES = \
Foundation/NSAttributedString.iOS.cs \
Foundation/EnumDesktop.cs \
Foundation/NSObject.mac.cs \
Foundation/NSDateComponents.cs \
FOUNDATION_SOURCES = \
Foundation/Additions.cs \

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

@ -0,0 +1,33 @@
using System;
#if XAMCORE_2_0
using Foundation;
#else
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
#endif
using NUnit.Framework;
namespace MonoTouchFixtures.Foundation {
[TestFixture]
[Preserve (AllMembers = true)]
public class NSDateComponentsTest {
[Test]
public void TestUndefinedComponent ()
{
// as per documentation:
// "When a new instance of NSDateComponents is created,
// the date components are set to
// NSDateComponentUndefined."
// we simply test that the values are undefined
var components = new NSDateComponents ();
Assert.AreEqual (NSDateComponents.Undefined, components.Year, $"Year");
Assert.AreEqual (NSDateComponents.Undefined, components.Month, "Month");
Assert.AreEqual (NSDateComponents.Undefined, components.Day, "Day");
Assert.AreEqual (NSDateComponents.Undefined, components.Hour, "Hour");
Assert.AreEqual (NSDateComponents.Undefined, components.Minute, "Minute");
Assert.AreEqual (NSDateComponents.Undefined, components.Second, "Second");
}
}
}