public void PeekingShouldThrowWhenIncorrectCharacterAtStart() { ExpressionLexer lexer = new ExpressionLexer("#$*@#", false, false); Action peek = () => lexer.PeekNextToken(); peek.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.ExpressionLexer_InvalidCharacter("#", "0", "#$*@#")); }
public void SemicolonOnlyAllowedInParensInExpand() { SelectExpandParser parser = new SelectExpandParser("one;two", 3); Action parse = () => parser.ParseExpand(); parse.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.ExpressionLexer_InvalidCharacter(";", 3, "one;two")); }
public void ParsePath_AliasInFunctionImport_InvalidAliasName() { Action parse = () => ParseUriAndVerify( new Uri("http://gobbledygook/GetPet4(id=@p!1)?@p!1=1.01M"), (oDataPath, filterClause, orderByClause, selectExpandClause, aliasNodes) => { }); parse.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.ExpressionLexer_InvalidCharacter("!", 5, "id=@p!1")); }
public void ShouldErrorWhenIncorrectCharacterAtStart() { ExpressionLexer lexer = new ExpressionLexer("#$*@#", false, false); ExpressionToken resultToken; Exception error = null; bool result = lexer.TryPeekNextToken(out resultToken, out error); result.Should().BeFalse(); error.Should().NotBeNull(); error.Message.Should().Be(ODataErrorStrings.ExpressionLexer_InvalidCharacter("#", "0", "#$*@#")); }
public void OverClosedBracketsThrow() { ValidateLexerException <ODataException>("{stuff: morestuff}}", ODataErrorStrings.ExpressionLexer_InvalidCharacter("}", "18", "{stuff: morestuff}}")); }
public void ExpressionLexerShouldExpectIdentifierStartAfterAtSymbol() { Action lex = () => new ExpressionLexer("@1", moveToFirstToken: true, useSemicolonDelimeter: false, parsingFunctionParameters: true); lex.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.ExpressionLexer_InvalidCharacter("1", 1, "@1")); }
public void ExpressionLexerShouldFailByDefaultForAtSymbol() { Action lex = () => new ExpressionLexer("@", moveToFirstToken: true, useSemicolonDelimeter: false); lex.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.ExpressionLexer_InvalidCharacter("@", 0, "@")); }