public void Execute_BasicMathValid_True()
        {
            var expressions = new List<ValuedExpression>();
            expressions.Add(new ValuedExpression("=4+4", 8));

            var validator = new RowValidator();
            var result = validator.Execute(new Dictionary<string, object>(), expressions).Aggregate<ExpressionEvaluationResult, bool>(true, (total, r) => total && r.IsValid);

            Assert.That(result, Is.True);
        }
        public void Execute_MathVariablesToleranceValid_True()
        {
            var expressions = new List<ValuedExpression>();
            expressions.Add(new ValuedExpression("=Abs(x*y)", 9, 2));
            var variables = new Dictionary<string, object>();
            variables["x"] = -5;
            variables["y"] = 2;

            var validator = new RowValidator();
            var result = validator.Execute(variables, expressions).Aggregate<ExpressionEvaluationResult, bool>(true, (total, r) => total && r.IsValid);

            Assert.That(result, Is.True);
        }
        protected bool doMatch(ResultSet actual)
        {
            this.actualResultSet = actual;

            var validationEngine = new RowValidator();
            evaluationResults = new List<RowEvaluationResult>();
            int rowIndex=0;
            foreach (DataRow row in actualResultSet.Rows)
            {
                var valuedVariables = new Dictionary<string, Object>();
                foreach (var v in variables)
                    valuedVariables.Add(v.Name, row[v.Column]);

                var valuedExpressions = new List<ValuedExpression>();
                foreach (var e in expressions)
                    valuedExpressions.Add(new ValuedExpression(e.Value, row[e.Column], e.Type, e.Tolerance));

                evaluationResults.Add(new RowEvaluationResult(rowIndex, valuedVariables, validationEngine.Execute(valuedVariables, valuedExpressions)));
                rowIndex += 1;
            }
            bool value = evaluationResults.Aggregate<RowEvaluationResult, bool>(true, (total, r) => total && (r.CountExpressionValidationFailed()==0));
            return value;
        }
        public void Execute_VariableInvalid_False()
        {
            var expressions = new List<ValuedExpression>();
            expressions.Add(new ValuedExpression("=X+4", 0));
            var variables = new Dictionary<string, object>();
            variables["X"] = 5;

            var validator = new RowValidator();
            var result = validator.Execute(variables, expressions).Aggregate<ExpressionEvaluationResult, bool>(true, (total, r) => total && r.IsValid);

            Assert.That(result, Is.False);
        }