public void ValidateWithSeveralOperatorsTogether() { string expression = "+ + 7"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsFalse(result); }
public void ValidateSimpleWrongExpression() { string expression = "2a7"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsFalse(result); }
public void ValidateWrongExpressionWithValidSubexpression() { string expression = "2 + 7 - 2 a 3 b"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsFalse(result); }
public void ValidateComplexExpression() { string expression = "2 + 7 - 2 * 4"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsTrue(result); }
public void ValidateComplexWrongExpression() { string expression = "2 + 7 a 2 b 4"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsFalse(result); }
public void ValidateFailsNoSpaces() { string expression = "2+7"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsFalse(result); }
public void ValidateWithSpaces() { string expression = "2 + 287"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsTrue(result); }
public void ValidateMoreThanOneDigitExpression() { string expression = "25 + 287"; bool result = MathRegex.IsExpressionValid(expression); Assert.IsTrue(result); }
public void ValidateSimpleExpressionWithAllOperations() { string operators = "+-*/"; string expression = String.Empty; foreach (char operatorChar in operators) { expression = "2 " + operatorChar + " 2"; Assert.IsTrue(MathRegex.IsExpressionValid(expression), "Failure with operator: " + operatorChar); } }
public void ValidateWithNegativeNumbers() { Assert.IsTrue(MathRegex.IsExpressionValid("-7 + 1")); }
public void ValidateWithNegativeNumbersAtTheEnd() { Assert.IsTrue(MathRegex.IsExpressionValid("7 - -1")); }