private bool IsEqual(ExpressionNode lhs, ExpressionNode rhs, TypeEnum type, List <object> parameters)
        {
            bool res = false;

            if (type == TypeEnum.Boolean)
            {
                bool lhsValue = _interpreter.DispatchBoolean(lhs, parameters);
                bool rhsValue = _interpreter.DispatchBoolean(rhs, parameters);
                res = lhsValue == rhsValue;
            }
            else if (type == TypeEnum.Real)
            {
                double lhsValue = _interpreter.DispatchReal(lhs, parameters);
                double rhsValue = _interpreter.DispatchReal(rhs, parameters);
                res = lhsValue == rhsValue;
            }
            else if (type == TypeEnum.Integer)
            {
                int lhsValue = _interpreter.DispatchInt(lhs, parameters);
                int rhsValue = _interpreter.DispatchInt(rhs, parameters);
                res = lhsValue == rhsValue;
            }
            else if (type == TypeEnum.Function)
            {
                Function lhsValue = _interpreter.DispatchFunction(lhs, parameters);
                Function rhsValue = _interpreter.DispatchFunction(rhs, parameters);
                res = lhsValue.Reference == rhsValue.Reference;
            }
            else if (type == TypeEnum.Set)
            {
                Set lhsValue = _interpreter.DispatchSet(lhs, parameters);
                Set rhsValue = _interpreter.DispatchSet(rhs, parameters);

                res = EquivalentSets(lhsValue, rhsValue);
            }
            else if (type == TypeEnum.Element)
            {
                Element lhsValue = _interpreter.DispatchElement(lhs, parameters);
                Element rhsValue = _interpreter.DispatchElement(rhs, parameters);

                res = lhsValue.Equals(rhsValue);
            }
            else
            {
                throw new Exception($"The type '{type}' cannot be used for equivalence");
            }
            return(res);
        }
        public void NotEqualBoolean_Function_CorrectValuesReturned(int lhsValue, int rhsValue, bool expected)
        {
            var lhs = Utilities.GetIntLitExpression();
            var rhs = Utilities.GetIntLitExpression();

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

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

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

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

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

            Assert.AreEqual(expected, res);
        }
        public void NotEqualBoolean_Function_CheckParametersPassedDown()
        {
            var lhs = Utilities.GetFuncCallExpresssion();
            var rhs = Utilities.GetFuncCallExpresssion();

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

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

            parent.DispatchFunction(lhs, Arg.Do <List <object> >(x => lhsParams = x)).Returns(new Function(0));
            parent.DispatchFunction(rhs, Arg.Do <List <object> >(x => rhsParams = x)).Returns(new Function(0));

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            booleanHelper.NotEqualBoolean(expression, parameters);

            Assert.AreEqual(expectedParams, lhsParams);
            Assert.AreEqual(expectedParams, rhsParams);
        }