public void TR35_Example_2() { var strings = StringRange.Enumerate("ab", "d").ToArray(); Assert.AreEqual(3, strings.Length); CollectionAssert.Contains(strings, "ab"); CollectionAssert.Contains(strings, "ac"); CollectionAssert.Contains(strings, "ad"); }
public void Errors() { ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => StringRange.Enumerate("", "a").ToArray()); ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => StringRange.Enumerate("ab", "ddx").ToArray()); // NYI ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => StringRange.Enumerate("ab", "cd").ToArray()); }
/// <summary> /// Determines if the code is defined. /// </summary> /// <param name="code"> /// The code to check. /// </param> /// <returns> /// <b>true</b> if the <paramref name="code"/> is defined; otherwise, <b>false</b>. /// </returns> public bool Contains(string code) { foreach (var defined in codes) { if (code == defined) { return(true); } var i = defined.IndexOf(Separator); if (i > 0) { var found = StringRange .Enumerate(defined.Substring(0, i), defined.Substring(i + 1)) .Any(c => c == code); if (found) { return(true); } } } return(false); }