public void PowerInteger_TwoIntsButNegativeExponent_ThrowsException(int input1, int input2) { IntegerLiteralExpression realLit1 = new IntegerLiteralExpression(input1, 1, 1); IntegerLiteralExpression realLit2 = new IntegerLiteralExpression(input2, 2, 2); PowerExpression powExpr = new PowerExpression(realLit1, realLit2, 1, 1); IInterpreterInteger parent = Substitute.For <IInterpreterInteger>(); parent.DispatchInt(realLit1, Arg.Any <List <object> >()).Returns(input1); parent.DispatchInt(realLit2, Arg.Any <List <object> >()).Returns(input2); IntegerHelper realHelper = SetUpHelper(parent); int res = realHelper.PowerInteger(powExpr, new List <object>()); }
public void PowerInteger_TwoInts_ReturnsCorrectResult(int input1, int input2, int expected) { IntegerLiteralExpression realLit1 = new IntegerLiteralExpression(input1, 1, 1); IntegerLiteralExpression realLit2 = new IntegerLiteralExpression(input2, 2, 2); PowerExpression powExpr = new PowerExpression(realLit1, realLit2, 1, 1); IInterpreterInteger parent = Substitute.For <IInterpreterInteger>(); parent.DispatchInt(realLit1, Arg.Any <List <object> >()).Returns(input1); parent.DispatchInt(realLit2, Arg.Any <List <object> >()).Returns(input2); IntegerHelper realHelper = SetUpHelper(parent); int res = realHelper.PowerInteger(powExpr, new List <object>()); Assert.AreEqual(expected, res); }