Exemple #1
0
        public void NewArrayInit()
        {
            NotSupportedException expectedException = new NotSupportedException(
                string.Format(ErrorStrings.UnsupportedExpressionType, ExpressionType.NewArrayInit));

            Activity we = ExpressionTestRuntime.Convert((env) => new int[] { 1, 2, 3 }, expectedException);
        }
        public void ConvertNull()
        {
            ArgumentNullException expectedException = new ArgumentNullException("expression", ErrorStrings.ExpressionRequiredForConversion);

            Expression <Func <ActivityContext, int> > expression = null;

            ExpressionTestRuntime.Convert(expression, expectedException);
        }
Exemple #3
0
        public void NewWithInitializer()
        {
            NotSupportedException expectedException = new NotSupportedException(
                string.Format(ErrorStrings.UnsupportedExpressionType, ExpressionType.MemberInit));

            ExpressionTestRuntime.Convert((env) => new DummyHelper()
            {
                StringVar = null
            }, expectedException);
        }
Exemple #4
0
        //  Unsupported binary operator
        public void UnsupportedBinaryOperator()
        {
            NodeExpressionPair node = ExpressionLeafs.UnsupportedBinaryOperator;
            Expression <Func <ActivityContext, int> > lambdaExpression = Expression.Lambda <Func <ActivityContext, int> >((Expression)node.LeafExpression, Expression.Parameter(typeof(ActivityContext), "context"));

            NotSupportedException expectedException = new NotSupportedException(
                string.Format(ErrorStrings.UnsupportedExpressionType, ExpressionType.Coalesce));

            ExpressionTestRuntime.Convert(lambdaExpression, expectedException);
        }
Exemple #5
0
        // Unsupported unary operator
        public void UnsupportedUnaryOperator()
        {
            NotSupportedException expectedException = new NotSupportedException(
                string.Format(ErrorStrings.UnsupportedExpressionType, ExpressionType.NegateChecked));

            Expression <Func <ActivityContext, int> > expression =
                Expression.Lambda <Func <ActivityContext, int> >(
                    Expression.MakeUnary(ExpressionType.NegateChecked, Expression.Constant(100), typeof(int)),
                    Expression.Parameter(typeof(ActivityContext), "context"));

            ExpressionTestRuntime.Convert(expression, expectedException);
        }
Exemple #6
0
        public static Activity ConvertAndValidate <TResult>(Expression <Func <ActivityContext, TResult> > expr, Activity expectedActivity, Exception expectedException)
        {
            bool     expectSuccess = expectedException == null ? true : false;
            Activity act           = ExpressionTestRuntime.Convert(expr, expectedException);

            if (expectSuccess)
            {
                ExpressionTestRuntime.ValidateActivity(expectedActivity, act);
            }

            act = ExpressionTestRuntime.TryConvert(expr, expectSuccess);
            if (expectSuccess)
            {
                ExpressionTestRuntime.ValidateActivity(expectedActivity, act);
            }

            return(act);
        }
Exemple #7
0
        //  Method call with VarArg
        public void MethodCallWithVarArg()
        {
            TargetInvocationException expectedException = new TargetInvocationException(null);

            ExpressionTestRuntime.Convert((env) => DummyHelper.MethodCallWithVarArg(1, 2, 3), expectedException);
        }