public void TryParsePassesResult(bool innerSuccess, string innerRemaining, string result) { var inner = StringParserTestUtils.MockParser("stat", innerSuccess, innerRemaining, result).Object; var sut = new ValidatingParser <string>(inner); var(_, _, actual) = sut.Parse("stat"); Assert.AreEqual(result, actual); }
public string TryParseReturnsCorrectRemaining(string innerRemaining) { var inner = StringParserTestUtils.MockParser("stat", true, innerRemaining, "").Object; var sut = new ValidatingParser <string>(inner); var(_, actual, _) = sut.Parse("stat"); return(actual); }
public void TryParseReturnsCorrectUnchangedRemaining(string remaining) { var inner = StringParserTestUtils.MockParser("stat", true, remaining, "").Object; var sut = new ValidatingParser <string>(inner); var(_, actual, _) = sut.Parse("stat"); Assert.AreEqual(remaining, actual); }
public bool TryParseWithoutReplacementPassesSuccessfullyParsed(bool innerSuccess) { var inner = StringParserTestUtils.MockParser("stat", innerSuccess, "", "").Object; var sut = new StatReplacingParser <string>(inner, _statReplacers); var(actual, _, _) = sut.Parse("stat"); return(actual); }
public bool TryParsePassesSuccessfullyParsed(bool innerSuccess) { var inner = StringParserTestUtils.MockParser("stat", innerSuccess, "", "").Object; var sut = new StatNormalizingParser <string>(inner); var(actual, _, _) = sut.Parse("stat"); return(actual); }
public void TryParseHiddenTestIsCaseInsensitive() { var remaining = ItemConstants.HiddenStatSuffix.ToLowerInvariant(); var inner = StringParserTestUtils.MockParser("stat", true, remaining, "").Object; var sut = new ValidatingParser <string>(inner); var(actual, _, _) = sut.Parse("stat"); Assert.True(actual); }
public void TryParseReturnsSuccessIfRemainingIsOnlyWhiteSpaceAndEndsWithHidden() { const string remaining = " \n\t\r" + ItemConstants.HiddenStatSuffix; var inner = StringParserTestUtils.MockParser("stat", true, remaining, "").Object; var sut = new ValidatingParser <string>(inner); var(actual, _, _) = sut.Parse("stat"); Assert.True(actual); }
public void TryParseReturnsFailureIfRemainingStartsWithHidden() { const string remaining = ItemConstants.HiddenStatSuffix + " "; var inner = StringParserTestUtils.MockParser("stat", true, remaining, "").Object; var sut = new ValidatingParser <string>(inner); var(actual, _, _) = sut.Parse("stat"); Assert.False(actual); }
public void TryParseReturnsFailureIfRemainingContainsNonWhiteSpace() { const string remaining = " r "; var inner = StringParserTestUtils.MockParser("stat", true, remaining, "").Object; var sut = new ValidatingParser <string>(inner); var(actual, _, _) = sut.Parse("stat"); Assert.False(actual); }
public void TryParseReturnsFailureIfInnerReturnsFailure() { const string remaining = " "; var inner = StringParserTestUtils.MockParser("stat", false, remaining, "").Object; var sut = new ValidatingParser <string>(inner); var(actual, _, _) = sut.Parse("stat"); Assert.False(actual); }
public void TryParseCleansIfInnerReturnsFalse() { const string innerRemaining = " \ntest\t\r " + ItemConstants.HiddenStatSuffix; var inner = StringParserTestUtils.MockParser("stat", true, innerRemaining, "").Object; var sut = new ValidatingParser <string>(inner); var(_, actual, _) = sut.Parse("stat"); Assert.AreEqual("test", actual); }
private static IStringParser <int> MockConstantParser(string stat, string remaining = "remaining", int result = 42, bool @return = true) { return(StringParserTestUtils.MockParser(stat, @return, remaining, result).Object); }
public bool TryParseWithoutReplacementPassesSuccessfullyParsed(bool innerSuccess) { var inner = StringParserTestUtils.MockParser("stat", innerSuccess, default, "").Object;
public void TryParseWithoutReplacementPassesRemaining() { const string expected = "remaining"; var inner = StringParserTestUtils.MockParser("stat", default, expected, "").Object;