public void ReturnsTrueAndXForTrueandXString() { var tr = new Text("true"); Assert.True(tr.Match("trueX").Success()); Assert.Equal("X", tr.Match("trueX").RemainingText()); }
public void NullDoesNotMatchEmptyText() { Text text = new Text(""); Assert.False(text.Match(null).Success()); Assert.True(text.Match(null).RemainingText() == null); }
public void PrefixTextNotMatch() { var prefix = new Text("false"); Assert.False(prefix.Match("Xfalse").Success()); Assert.Equal("Xfalse", prefix.Match("Xfalse").RemainingText()); }
public void LowerCaseStringMatchesLowerCaseText() { Text text = new Text("true"); Assert.True(text.Match("true").Success()); Assert.True(text.Match("true").RemainingText()?.Length == 0); }
public void EmptyStringMatchesEmptyText() { Text text = new Text(""); Assert.True(text.Match("").Success()); Assert.True(text.Match("").RemainingText()?.Length == 0); }
public void LowerAndUpperCaseStringMatchesLowerCaseText() { Text text = new Text("false"); Assert.True(text.Match("falseX").Success()); Assert.True(text.Match("falseX").RemainingText() == "X"); }
public void StringDoesNotMatchText() { Text text = new Text("false"); Assert.False(text.Match("true").Success()); Assert.True(text.Match("true").RemainingText() == "true"); }
public void EmptyStringDoesNotMatchText() { Text text = new Text("true"); Assert.False(text.Match("").Success()); Assert.True(text.Match("").RemainingText()?.Length == 0); }
public void CanMatchLeadingCharactersByPredicate() { Predicate<char> letters = Char.IsLetter; Predicate<char> digits = Char.IsDigit; Predicate<char> alphanumerics = Char.IsLetterOrDigit; var empty = new Text(""); empty.Match(letters).ShouldFail(); var abc123 = new Text("abc123"); abc123.Match(digits).ShouldFail(); abc123.Match(letters).ShouldSucceed("abc"); abc123.Match(alphanumerics).ShouldSucceed("abc123"); abc123.Advance(2).Match(digits).ShouldFail(); abc123.Advance(2).Match(letters).ShouldSucceed("c"); abc123.Advance(2).Match(alphanumerics).ShouldSucceed("c123"); abc123.Advance(3).Match(digits).ShouldSucceed("123"); abc123.Advance(3).Match(letters).ShouldFail(); abc123.Advance(3).Match(alphanumerics).ShouldSucceed("123"); abc123.Advance(6).Match(digits).ShouldFail(); abc123.Advance(6).Match(letters).ShouldFail(); abc123.Advance(6).Match(alphanumerics).ShouldFail(); }
public void LowerCaseStringMatchesEmptyText() { Text text = new Text(""); Assert.True(text.Match("true").Success()); Assert.True(text.Match("true").RemainingText() == "true"); }
public void CanMatchLeadingCharactersByTokenRegex() { var end = new TokenRegex(@"$"); var letters = new TokenRegex(@"[a-z]+"); var digits = new TokenRegex(@"[0-9]+"); var alphanumerics = new TokenRegex(@"[a-z0-9]+"); var empty = new Text(""); empty.Match(letters).ShouldFail(); empty.Match(end).ShouldSucceed(""); var abc123 = new Text("abc123"); abc123.Match(digits).ShouldFail(); abc123.Match(letters).ShouldSucceed("abc"); abc123.Match(alphanumerics).ShouldSucceed("abc123"); abc123.Advance(2).Match(digits).ShouldFail(); abc123.Advance(2).Match(letters).ShouldSucceed("c"); abc123.Advance(2).Match(alphanumerics).ShouldSucceed("c123"); abc123.Advance(3).Match(digits).ShouldSucceed("123"); abc123.Advance(3).Match(letters).ShouldFail(); abc123.Advance(3).Match(alphanumerics).ShouldSucceed("123"); abc123.Advance(6).Match(digits).ShouldFail(); abc123.Advance(6).Match(letters).ShouldFail(); abc123.Advance(6).Match(alphanumerics).ShouldFail(); }
public void CanMatchLeadingCharactersByPredicate() { Predicate <char> letters = Char.IsLetter; Predicate <char> digits = Char.IsDigit; Predicate <char> alphanumerics = Char.IsLetterOrDigit; var empty = new Text(""); empty.Match(letters).ShouldFail(); var abc123 = new Text("abc123"); abc123.Match(digits).ShouldFail(); abc123.Match(letters).ShouldSucceed("abc"); abc123.Match(alphanumerics).ShouldSucceed("abc123"); abc123.Advance(2).Match(digits).ShouldFail(); abc123.Advance(2).Match(letters).ShouldSucceed("c"); abc123.Advance(2).Match(alphanumerics).ShouldSucceed("c123"); abc123.Advance(3).Match(digits).ShouldSucceed("123"); abc123.Advance(3).Match(letters).ShouldFail(); abc123.Advance(3).Match(alphanumerics).ShouldSucceed("123"); abc123.Advance(6).Match(digits).ShouldFail(); abc123.Advance(6).Match(letters).ShouldFail(); abc123.Advance(6).Match(alphanumerics).ShouldFail(); }
public void NullDoesNotMatchLowerCaseText() { Text text = new Text("true"); Assert.False(text.Match(null).Success()); Assert.True(text.Match(null).RemainingText() == null); }
public void ReturnsFalseAndEmptyForEmptyString() { var tr = new Text("true"); Assert.False(tr.Match("").Success()); Assert.Equal("", tr.Match("").RemainingText()); }
public void EmptyTextReturnFalse() { var truee = new Text("true"); Assert.False(truee.Match(string.Empty).Success()); Assert.Empty(truee.Match("").RemainingText()); }
public void EmptyPrefixTextMatchEmpty() { var empty = new Text(""); Assert.True(empty.Match("ceva").Success()); Assert.Equal("ceva", empty.Match("ceva").RemainingText()); }
public void NullTextReturnFalse() { var truee = new Text("true"); Assert.False(truee.Match(null).Success()); Assert.Null(truee.Match(null).RemainingText()); }
public void LowerCaseStringMatchesStringWithLowerCapsAndUpperCase() { Text text = new Text("true"); Assert.True(text.Match("trueX").Success()); Assert.True(text.Match("trueX").RemainingText() == "X"); }
public void ReturnsTrueAndTextForEmptyPrefix() { var empty = new Text(""); Assert.True(empty.Match("true").Success()); Assert.Equal("true", empty.Match("true").RemainingText()); }
public void For_Constructor_False_And_Text_Null_Should_Return_Null() { var isFalse = new Text("false"); IMatch actual = isFalse.Match(null); Assert.Null(actual.RemainingText()); }
public void For_Constructor_True_And_Text_Empty_String_Should_Return_Empty_String() { var isTrue = new Text("true"); IMatch actual = isTrue.Match(string.Empty); Assert.Equal(string.Empty, actual.RemainingText()); }
public void For_Constructor_True_And_Text_NUll_Should_Return_null() { var isTrue = new Text("true"); IMatch actual = isTrue.Match(null); Assert.Equal(null, actual.RemainingText()); }
public void For_Constructor_True_And_Text_Null_Should_Return_False() { var isTrue = new Text("true"); IMatch actual = isTrue.Match(null); Assert.False(actual.Succes()); }
public void For_Constructor_True_And_Text_Truex_Should_Return_True() { var isTrue = new Text("true"); IMatch actual = isTrue.Match("truex"); Assert.True(actual.Succes()); }
public void For_Constructor_True_And_Text_False_Should_Return_Text_false() { var isTrue = new Text("true"); IMatch actual = isTrue.Match("false"); Assert.Equal("false", actual.RemainingText()); }
public void For_Constructor_Empty_String_And_Text_Null_Should_Return_False() { var isFalse = new Text(string.Empty); IMatch actual = isFalse.Match(null); Assert.False(actual.Succes()); }
public void For_Constructor_Empty_String_And_Text_Null_Should_Return_null() { var isFalse = new Text(string.Empty); IMatch actual = isFalse.Match(null); Assert.Null(actual.RemainingText()); }
public void For_Constructor_False_And_Text_Falsex_Should_Return_Text_x() { var isFalse = new Text("false"); IMatch actual = isFalse.Match("falsex"); Assert.Equal("x", actual.RemainingText()); }
public void For_Constructor_Empty_String_And_Text_True_Should_Return_Text_True() { var isFalse = new Text(string.Empty); IMatch actual = isFalse.Match("true"); Assert.Equal("true", actual.RemainingText()); }
public void For_Constructor_False_And_Text_False_Should_Return_Text_Emprty_String() { var isFalse = new Text("false"); IMatch actual = isFalse.Match("false"); Assert.Equal(string.Empty, actual.RemainingText()); }
public void For_Constructor_False_And_Text_True_Should_Return_False() { var isFalse = new Text("false"); IMatch actual = isFalse.Match("true"); Assert.False(actual.Succes()); }