internal void WhereBuilder_ValidateSymbolILogicalOperator_InvalidProceeding_ThrowsException( ILogicalOperatorSymbol symbol, ISequenceSymbol nextSymbol) { // Act && Assert var ex = Assert.Throws <ParseException>(() => this._fixture.SequenceOfSymbolsValidator.ValidateSymbol(symbol, nextSymbol, 1)); Assert.StartsWith(ValidationErrorResources.SequenceOfSymbols_AfterLogicalOperatorThereMustBeOpeningParenthesisOrExpression, ex.Message); }
public void ValidateSymbol(ExpressionSymbol <T> sequenceSymbol, ISequenceSymbol nextSymbol) { if (!this.allowedSymbolsAfterExpression.Contains(nextSymbol?.GetType())) { throw new ParseException( ValidationErrorResources.SequenceOfSymbols_AfterExpressionThereMustBeLogicalOperatorOrClosingParenthesis, sequenceSymbol.QueryPartIndex); } }
internal void ExpressionCollectionBuilder_HitsInvalidSymbol_ThrowsException(ISequenceSymbol sequenceSymbol) { // Arrange var sequenceOfSymbols = new List <ISequenceSymbol>(); sequenceOfSymbols.Add(sequenceSymbol); // Act & Assert var ex = Assert.Throws <NotImplementedException>(() => this._fixture._expressionCollectionBuilder.Build(sequenceOfSymbols)); Assert.Equal(string.Format(GeneralResources.Exception_UnexpectedTokenDuringAnalysisOfSequenceOfSymbols, sequenceSymbol.GetType()), ex.Message); }
public void ValidateSymbol(ILogicalOperatorSymbol sequenceSymbol, ISequenceSymbol nextSymbol, int i) { if (i == 0) { throw new ParseException( ValidationErrorResources.SequenceOfSymbols_QueryCannotBeginWithLogicalOperator, (sequenceSymbol as ISequenceSymbol).QueryPartIndex); } if (!this.allowedSymbolsAfterLogicalOperator.Contains(nextSymbol?.GetType())) { throw new ParseException( ValidationErrorResources.SequenceOfSymbols_AfterLogicalOperatorThereMustBeOpeningParenthesisOrExpression, (sequenceSymbol as ISequenceSymbol).QueryPartIndex); } }
public void ValidateSymbol(IParenthesisSymbol sequenceSymbol, ISequenceSymbol nextSymbol, int i, ref int parenthesisCount) { switch (sequenceSymbol) { case ParenthesisOpenSymbol _: parenthesisCount++; if (!this.allowedSymbolsAfterParenthesisOpen.Contains(nextSymbol?.GetType())) { throw new ParseException( ValidationErrorResources.SequenceOfSymbols_AfterOpeningParenthesisThereMustBeExpressionOrOpeningParenthesis, (sequenceSymbol as ISequenceSymbol).QueryPartIndex); } break; case ParenthesisCloseSymbol _: if (i == 0) { throw new ParseException( ValidationErrorResources.SequenceOfSymbols_QueryCannotBeginWithClosingParenthesis, (sequenceSymbol as ISequenceSymbol).QueryPartIndex); } parenthesisCount--; if (!this.allowedSymbolsAfterParenthesisClose.Contains(nextSymbol?.GetType())) { throw new ParseException( ValidationErrorResources.SequenceOfSymbols_AfterClosingParenthesisThereMustBeLogicalOperatorOrClosingParenthesis, (sequenceSymbol as ISequenceSymbol).QueryPartIndex); } break; default: // should not happen throw new ParseException( string.Format(ValidationErrorResources.SequenceOfSymbols_UnknownParenthesisSymbolX, sequenceSymbol.GetType()), (sequenceSymbol as ISequenceSymbol).QueryPartIndex); } }
internal void SequenceOfSymbolsBuilder_QueryBeginsWithValidSymbols_DoesNotThrowException( ISequenceSymbol sequenceSymbol, ISequenceSymbol nextSequenceSymbol1, ISequenceSymbol nextSequenceSymbol2) { // Arrange var sequenceOfSymbols = new List <ISequenceSymbol>(); sequenceOfSymbols.Add(sequenceSymbol); if (nextSequenceSymbol1 != null) { sequenceOfSymbols.Add(nextSequenceSymbol1); } if (nextSequenceSymbol2 != null) { sequenceOfSymbols.Add(nextSequenceSymbol2); } // Act this._fixture.SequenceOfSymbolsValidator.Validate(sequenceOfSymbols); }
internal void SequenceOfSymbolsBuilder_QueryBeginsWithInvalidSymbols_ThrowsException(ISequenceSymbol sequenceSymbol, string expectedExceptionMessage) { // Arrange var sequenceOfSymbols = new List <ISequenceSymbol>(); sequenceOfSymbols.Add(sequenceSymbol); // Act & Assert var ex = Assert.Throws <ParseException>(() => this._fixture.SequenceOfSymbolsValidator.Validate(sequenceOfSymbols)); Assert.StartsWith(expectedExceptionMessage, ex.Message); }
internal void WhereBuilder_ValidateSymbolParenthesisClose_ValidProceeding_DoesnNotThrowException(ISequenceSymbol nextSymbol) { // Arrange var parenthesisCount = 0; // Act this._fixture.SequenceOfSymbolsValidator.ValidateSymbol(new ParenthesisCloseSymbol(0), nextSymbol, 1, ref parenthesisCount); }
internal void WhereBuilder_ValidateSymbolExpression_ParenthesisClose_ThrowsException(ISequenceSymbol nextSymbol) { // Arrange var parenthesisCount = 0; // Act && Assert var ex = Assert.Throws <ParseException>(() => this._fixture.SequenceOfSymbolsValidator.ValidateSymbol(new ParenthesisCloseSymbol(0), nextSymbol, 1, ref parenthesisCount)); Assert.StartsWith(ValidationErrorResources.SequenceOfSymbols_AfterClosingParenthesisThereMustBeLogicalOperatorOrClosingParenthesis, ex.Message); }
internal void WhereBuilder_ValidateSymbolExpression_ValidProceeding_DoesnNotThrowException(ISequenceSymbol nextSymbol) { // Act this._fixture.SequenceOfSymbolsValidator.ValidateSymbol(new ExpressionSymbol <object>(0, null), nextSymbol); }
internal void WhereBuilder_ValidateSymbolExpression_InvalidProceeding_ThrowsException(ISequenceSymbol nextSymbol) { // Act && Assert var ex = Assert.Throws <ParseException>(() => this._fixture.SequenceOfSymbolsValidator.ValidateSymbol(new ExpressionSymbol <object>(0, null), nextSymbol)); Assert.StartsWith(ValidationErrorResources.SequenceOfSymbols_AfterExpressionThereMustBeLogicalOperatorOrClosingParenthesis, ex.Message); }
internal void WhereBuilder_ValidateSymbolILogicalOperator_ValidProceeding_DoesnNotThrowException(ILogicalOperatorSymbol symbol, ISequenceSymbol nextSymbol) { // Act this._fixture.SequenceOfSymbolsValidator.ValidateSymbol(symbol, nextSymbol, 1); }