public void Dispatch_INonIdentifierAndStringList_CorrectIdentifierExpPassed()
        {
            PowerExpression expected = new PowerExpression(null, null, 1, 1);
            PowerExpression input1   = expected;
            List <string>   input2   = new List <string>()
            {
                "id"
            };
            IReferenceHelper         helper     = Substitute.For <IReferenceHelper>();
            ReferenceHandler         refHandler = new ReferenceHandler(helper);
            INonIdentifierExpression res        = null;

            helper.VisitNonIdentifier(Arg.Do <INonIdentifierExpression>(x => res = x), Arg.Any <List <string> >());

            refHandler.Dispatch(input1, input2);

            res.Should().BeEquivalentTo(expected);
        }
        public void Dispatch_FunctionCallExprAndStringList_CorrectFunctionCallExprPassed()
        {
            FunctionCallExpression expected = new FunctionCallExpression("func", null, 0, 0);
            FunctionCallExpression input1   = expected;
            List <string>          input2   = new List <string>()
            {
                "id"
            };
            IReferenceHelper       helper     = Substitute.For <IReferenceHelper>();
            ReferenceHandler       refHandler = new ReferenceHandler(helper);
            FunctionCallExpression res        = null;

            helper.VisitFunctionCall(Arg.Do <FunctionCallExpression>(x => res = x), Arg.Any <List <string> >());

            refHandler.Dispatch(input1, input2);

            res.Should().BeEquivalentTo(expected);
        }
        public void InsertReferences_AST_CorrectNumberOfCallsToBuildTable()
        {
            List <ExportNode> exports = new List <ExportNode> {
                new ExportNode(null, 0, 0),
                new ExportNode(null, 0, 0),
                new ExportNode(null, 0, 0)
            };
            List <FunctionNode> functions = new List <FunctionNode> {
                new FunctionNode("", null, null, null, 0, 0),
                new FunctionNode("", null, null, null, 0, 0),
                new FunctionNode("", null, null, null, 0, 0),
                new FunctionNode("", null, null, null, 0, 0)
            };
            AST ast = new AST(functions, exports, 0, 0);
            IReferenceHelper helper     = Substitute.For <IReferenceHelper>();
            ReferenceHandler refHandler = new ReferenceHandler(helper);

            refHandler.InsertReferences(ast);

            // helper.Received(1).BuildTable(Arg.Any<List<FunctionNode>>());
        }
        public void Dispatch_IdentifierExpAndStringList_CorrectListPassedToVisitIdentifier()
        {
            List <string> expected = new List <string>()
            {
                "id"
            };
            IdentifierExpression input1 = new IdentifierExpression("id", 1, 1);
            List <string>        input2 = new List <string>()
            {
                "id"
            };
            IReferenceHelper helper     = Substitute.For <IReferenceHelper>();
            ReferenceHandler refHandler = new ReferenceHandler(helper);
            List <string>    res        = new List <string>();

            helper.VisitIdentifier(Arg.Any <IdentifierExpression>(), Arg.Do <List <string> >(x => res = x));

            refHandler.Dispatch(input1, input2);

            res.Should().BeEquivalentTo(expected);
        }
 public ReferenceHandler(IReferenceHelper helper)
 {
     _helper = helper;
     _helper.SetDispatch(Dispatch);
 }
 public ReferenceHandler(IReferenceHelper helper, bool catchExceptions) : this(helper)
 {
     _catchExceptions = catchExceptions;
     _exceptions      = new ComponentException();
 }