public void AndBoolean__CorrectValuesReturned(bool lhsValue, bool rhsValue, bool expected)
        {
            BooleanLiteralExpression lhs = new BooleanLiteralExpression(lhsValue, 0, 0);
            BooleanLiteralExpression rhs = new BooleanLiteralExpression(rhsValue, 0, 0);

            AndExpression       andExpr = new AndExpression(lhs, rhs, 0, 0);
            IInterpreterBoolean parent  = Substitute.For <IInterpreterBoolean>();

            parent.DispatchBoolean(lhs, Arg.Any <List <object> >()).Returns(lhsValue);
            parent.DispatchBoolean(rhs, Arg.Any <List <object> >()).Returns(rhsValue);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.AndBoolean(andExpr, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public bool AndBoolean(AndExpression node, List <object> parameters)
        {
            bool leftOperand  = _interpreter.DispatchBoolean(node.Children[0], parameters);
            bool rightOperand = _interpreter.DispatchBoolean(node.Children[1], parameters);

            return(leftOperand && rightOperand);
        }
        public void NotEqualBoolean_Bool_CorrectValuesReturned(bool lhsValue, bool rhsValue, bool expected)
        {
            var lhs = Utilities.GetRealLitExpression();
            var rhs = Utilities.GetRealLitExpression();

            var expression = new NotEqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Boolean;
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchBoolean(lhs, Arg.Any <List <object> >()).Returns(lhsValue);
            parent.DispatchBoolean(rhs, Arg.Any <List <object> >()).Returns(rhsValue);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.NotEqualBoolean(expression, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void AndBoolean__CheckParametersPassedDown()
        {
            BooleanLiteralExpression lhs = Utilities.GetBoolLitExpression();
            BooleanLiteralExpression rhs = Utilities.GetBoolLitExpression();

            List <object>       parameters     = Utilities.GetParameterList(4);
            List <object>       expectedParams = parameters;
            var                 expression     = new AndExpression(lhs, rhs, 0, 0);
            IInterpreterBoolean parent         = Substitute.For <IInterpreterBoolean>();
            List <object>       lhsParams      = new List <object>();
            List <object>       rhsParams      = new List <object>();

            parent.DispatchBoolean(lhs, Arg.Do <List <object> >(x => lhsParams = x));
            parent.DispatchBoolean(rhs, Arg.Do <List <object> >(x => rhsParams = x));

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            booleanHelper.AndBoolean(expression, parameters);

            Assert.AreEqual(expectedParams, lhsParams);
            Assert.AreEqual(expectedParams, rhsParams);
        }
        public void NotEqualBoolean_Bool_CheckParametersPassedDown()
        {
            var lhs = Utilities.GetBoolLitExpression();
            var rhs = Utilities.GetBoolLitExpression();

            List <object> parameters     = Utilities.GetParameterList(4);
            List <object> expectedParams = parameters;
            var           expression     = new NotEqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Boolean;
            IInterpreterBoolean parent    = Substitute.For <IInterpreterBoolean>();
            List <object>       lhsParams = new List <object>();
            List <object>       rhsParams = new List <object>();

            parent.DispatchBoolean(lhs, Arg.Do <List <object> >(x => lhsParams = x));
            parent.DispatchBoolean(rhs, Arg.Do <List <object> >(x => rhsParams = x));

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            booleanHelper.NotEqualBoolean(expression, parameters);

            Assert.AreEqual(expectedParams, lhsParams);
            Assert.AreEqual(expectedParams, rhsParams);
        }
        public void NotBoolean_CorrectValuesReturned(bool input, bool expected)
        {
            BooleanLiteralExpression child = Utilities.GetBoolLitExpression(input);

            var expr = new NotExpression(child, 0, 0);
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchBoolean(child, Arg.Any <List <object> >()).Returns(input);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.NotBoolean(expr, new List <object>());

            Assert.AreEqual(expected, res);
        }