Example #1
0
        public void SetUp()
        {
            _exception           = new InvalidOperationException("What");
            _evaluatedExpression = ExpressionHelper.CreateExpression(typeof(double));

            _exceptionExpression = new PartialEvaluationExceptionExpression(_exception, _evaluatedExpression);
        }
        public void Evaluate_PartialEvaluationExceptionExpression_NotEvaluatable()
        {
            var expression = new PartialEvaluationExceptionExpression(new Exception(), Expression.Constant(1));
            var result     = PartialEvaluatingExpressionVisitor.EvaluateIndependentSubtrees(expression, new TestEvaluatableExpressionFilter());

            Assert.That(result, Is.SameAs(expression));
        }
        public Expression VisitPartialEvaluationException(PartialEvaluationExceptionExpression partialEvaluationExceptionExpression)
        {
            ArgumentUtility.CheckNotNull("partialEvaluationExceptionExpression", partialEvaluationExceptionExpression);

            // PartialEvaluationExceptionExpression is not evaluable, and its children aren't either (so we don't visit them).
            _isCurrentSubtreeEvaluatable = false;
            return(partialEvaluationExceptionExpression);
        }
        public void PartialEvaluationExceptionExpression_NotEvaluable_AndChildrenNeither()
        {
            var inner = Expression.Constant(0);
            var partialEvaluationExceptionExpression = new PartialEvaluationExceptionExpression(new Exception(), inner);

            var evaluationInfo = EvaluatableTreeFindingExpressionTreeVisitor.Analyze(partialEvaluationExceptionExpression);

            Assert.That(evaluationInfo.IsEvaluatableExpression(partialEvaluationExceptionExpression), Is.False);
            Assert.That(evaluationInfo.IsEvaluatableExpression(inner), Is.False);
        }
Example #5
0
        public void VisitPartialEvaluationExceptionExpression_StripsExceptionAndVisitsInnerExpression()
        {
            var evaluatedExpression = Expression.Property(Expression.Constant(""), "Length");
            var exception           = new InvalidOperationException("What?");
            var expression          = new PartialEvaluationExceptionExpression(exception, evaluatedExpression);

            var result = SqlPreparationExpressionVisitor.TranslateExpression(expression, _context, _stageMock, _methodCallTransformerProvider);

            var expectedExpression = new SqlLengthExpression(evaluatedExpression.Expression);

            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedExpression, result);
        }
Example #6
0
 public Expression VisitPartialEvaluationException(PartialEvaluationExceptionExpression partialEvaluationExceptionExpression)
 {
     throw new HibernateException(
               $"Evaluation failure on {partialEvaluationExceptionExpression.EvaluatedExpression}",
               partialEvaluationExceptionExpression.Exception);
 }
Example #7
0
 public Expression VisitPartialEvaluationException(PartialEvaluationExceptionExpression expression)
 {
     return(Visit(expression.Reduce()));
 }
 public Expression VisitPartialEvaluationExceptionExpression(PartialEvaluationExceptionExpression partialEvaluationExceptionExpression)
 {
     // PartialEvaluationExceptionExpression is not evaluable, and its children aren't either (so we don't visit them).
     _isCurrentSubtreeEvaluatable = false;
     return(partialEvaluationExceptionExpression);
 }
Example #9
0
        public virtual Expression VisitPartialEvaluationException(PartialEvaluationExceptionExpression partialEvaluationExceptionExpression)
        {
            ArgumentUtility.CheckNotNull("partialEvaluationExceptionExpression", partialEvaluationExceptionExpression);

            return(Visit(partialEvaluationExceptionExpression.EvaluatedExpression));
        }