public void EvaluateTests(string expression, int expectedResult) { var divExpression = new DivExpression(); int result = divExpression.Evaluate(expression); Assert.That(result, Is.EqualTo(expectedResult)); }
public void RaiseIfDivideRealByInteger() { DivExpression expr = new DivExpression(new ConstantExpression(6.5), new ConstantExpression(2)); try { expr.Evaluate(null); Assert.Fail(); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(InvalidCastException)); } }
public void DivideTwoIntegersWithTruncation() { DivExpression expr = new DivExpression(new ConstantExpression(5), new ConstantExpression(2)); Assert.AreEqual(2, expr.Evaluate(null)); }
public void DivideTwoIntegers() { DivExpression expr = new DivExpression(new ConstantExpression(6), new ConstantExpression(2)); Assert.AreEqual(3, expr.Evaluate(null)); }
public void EvaluateDivideByZero() { var divExpression = new DivExpression(); Assert.Throws(typeof(DivideByZeroException), () => divExpression.Evaluate("div(1,0)")); }
public void ErrorEvaluateTests(string expression) { var divExpression = new DivExpression(); Assert.Throws(typeof(ArithmeticException), () => divExpression.Evaluate(expression)); }