xamarin-macios/tests/introspection/Mac/MacApiTypoTest.cs

49 строки
1.0 KiB
C#
Исходник Обычный вид История

2016-11-22 00:35:57 +03:00
using System;
using NUnit.Framework;
#if XAMCORE_2_0
using Foundation;
using ObjCRuntime;
using AppKit;
#else
using MonoMac;
using MonoMac.Foundation;
using MonoMac.ObjCRuntime;
using MonoMac.AppKit;
#endif
namespace Introspection
{
[TestFixture]
public class MacApiTypoTest : ApiTypoTest
{
NSSpellChecker checker = new NSSpellChecker ();
[SetUp]
public void SetUp ()
{
var sdk = new Version (Constants.SdkVersion);
if (!PlatformHelper.CheckSystemVersion (sdk.Major, sdk.Minor))
Assert.Ignore ("Typos only verified using the latest SDK");
}
public override string GetTypo (string txt)
{
var checkRange = new NSRange (0, txt.Length);
var typoRange = checker.CheckSpelling (txt, 0);
if (typoRange.Length == 0)
return String.Empty;
return txt.Substring ((int)typoRange.Location, (int)typoRange.Length);
}
public override bool Skip (Type baseType, string typo)
{
if (baseType == typeof (NSSpellCheckerCanidates))
return true;
return base.Skip (baseType, typo);
}
2016-11-22 00:35:57 +03:00
}
}