Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void ConvertNull()
        {
            ArgumentNullException expectedException = new ArgumentNullException("expression", ErrorStrings.ExpressionRequiredForConversion);

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

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

            ExpressionTestRuntime.Convert((env) => new DummyHelper()
            {
                StringVar = null
            }, expectedException);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
0
        //  Method call with VarArg
        public void MethodCallWithVarArg()
        {
            TargetInvocationException expectedException = new TargetInvocationException(null);

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