public void Dispatch_IntegerLiteralAndObjectListAndIntegerType_CorrectValueReturned() { int expected = 17; IntegerLiteralExpression input1 = new IntegerLiteralExpression("", 0, 0); List <Object> input2 = new List <Object>() { 23, 2.334, null }; IIntegerHelper ihelper = Substitute.For <IIntegerHelper>(); Interpreter interpreter = Utilities.GetIntepreterOnlyWith(ihelper); ihelper.LiteralInteger(Arg.Any <IntegerLiteralExpression>(), Arg.Any <List <Object> >()).Returns(expected); int res = (int)interpreter.Dispatch(input1, input2, TypeEnum.Integer); Assert.AreEqual(expected, res); }
public void Dispatch_IntegerLiteralAndObjectListAndIntegerType_CorrectListPassed() { List <Object> expected = new List <Object>() { 23, 2.334, null }; IntegerLiteralExpression input1 = new IntegerLiteralExpression("", 0, 0); IIntegerHelper ihelper = Substitute.For <IIntegerHelper>(); Interpreter interpreter = Utilities.GetIntepreterOnlyWith(ihelper); List <Object> res = null; ihelper.LiteralInteger(Arg.Any <IntegerLiteralExpression>(), Arg.Do <List <Object> >(x => res = x)); interpreter.Dispatch(input1, expected, TypeEnum.Integer); res.Should().BeEquivalentTo(expected); }
public void DispatchInteger_IntegerLiteralAndObjectList_CorrectIntegerLiteralExprPassed() { IntegerLiteralExpression expected = new IntegerLiteralExpression("", 0, 0); IntegerLiteralExpression input1 = expected; List <Object> input2 = new List <Object>() { 23, 2.334, null }; IIntegerHelper ihelper = Substitute.For <IIntegerHelper>(); Interpreter interpreter = Utilities.GetIntepreterOnlyWith(ihelper); IntegerLiteralExpression res = null; ihelper.LiteralInteger(Arg.Do <IntegerLiteralExpression>(x => res = x), Arg.Any <List <Object> >()); interpreter.DispatchInt(input1, input2); res.Should().BeEquivalentTo(expected); }