public void Replace() { using (var s = new NSMutableString(0)) { s.SetString((NSString)"Hello World"); var number = s.ReplaceOcurrences((NSString)"World", (NSString)"Xamarin", NSStringCompareOptions.CaseInsensitiveSearch, new NSRange(0, s.Length)); #if XAMCORE_2_0 Assert.That(number, Is.EqualTo((nuint)1), "Number of replacements"); #else Assert.That(number, Is.EqualTo(1), "Number of replacements"); #endif Assert.That(s.ToString(), Is.EqualTo("Hello Xamarin"), "replaced"); Assert.Throws <ArgumentOutOfRangeException> (delegate { s.ReplaceOcurrences((NSString)"Xamarin", (NSString)"World!", NSStringCompareOptions.CaseInsensitiveSearch, new NSRange(0, s.Length + 1)); }, "bad 1"); Assert.Throws <ArgumentOutOfRangeException> (delegate { s.ReplaceOcurrences((NSString)"Xamarin", (NSString)"World!", NSStringCompareOptions.CaseInsensitiveSearch, new NSRange(1, s.Length)); }, "bad 2"); } }