Esempio n. 1
0
        private Expression <Action> GetActionForConstant(ConstantExpression constantExpression, Expression resultExpression, ExpressionType expressionType, string lambdaString)
        {
            if (constantExpression.Value == null)
            {
                if (expressionType == ExpressionType.Equal)
                {
                    return(AssertBuilder.GetIsNullAction(resultExpression, lambdaString));
                }
                else
                {
                    return(AssertBuilder.GetIsNotNullAction(resultExpression, lambdaString));
                }
            }

            var value = (bool)constantExpression.Value;

            if (expressionType == ExpressionType.NotEqual)
            {
                value = !value;
            }

            return(value
                       ? AssertBuilder.GetIsTrueAction(resultExpression, lambdaString)
                       : AssertBuilder.GetIsFalseAction(resultExpression, lambdaString));
        }
Esempio n. 2
0
 public override Expression <Action> GetAction(Expression expression)
 {
     return(AssertBuilder.GetIsTrueAction(expression, expression.PrettyPrint()));
 }