private StringHelper SetUpHelper(IInterpreterString parent)
        {
            StringHelper stringHelper = new StringHelper();

            stringHelper.SetInterpreter(parent);
            return(stringHelper);
        }
        public void AdditionString_StringAndString_ReturnsConcatenatedString(string input1, string input2, string expected)
        {
            StringLiteralExpression strLit1 = new StringLiteralExpression(input1.ToString(), 1, 1);
            StringLiteralExpression strLit2 = new StringLiteralExpression(input2.ToString(), 2, 2);
            AdditionExpression      addExpr = new AdditionExpression(strLit1, strLit2, 1, 1);
            IInterpreterString      parent  = Substitute.For <IInterpreterString>();

            parent.DispatchString(strLit1, Arg.Any <List <object> >()).Returns(input1);
            parent.DispatchString(strLit2, Arg.Any <List <object> >()).Returns(input2);
            StringHelper stringHelper = SetUpHelper(parent);

            string res = stringHelper.AdditionString(addExpr, new List <object>());

            Assert.AreEqual(expected, res);
        }
Esempio n. 3
0
 public void SetInterpreter(IInterpreterString interpreter)
 {
     _interpreter = interpreter;
 }