コード例 #1
0
        public void ExpressionRewriterConstantExercise()
        {
            foreach (var input in new []
            {
                new { Exception = typeof(NotSupportedException), AllowOuterVariables = false, ConstantExpression = Expression.Constant(Guid.NewGuid(), typeof(Guid)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(null, typeof(StringComparer)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant(null, typeof(StringComparer)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(Guid.NewGuid(), typeof(Guid)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant("abcd", typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant("abcd", typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant(null, typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(null, typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant(42, typeof(int)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(42, typeof(int)) },
            })
            {
                var rewriter = new ExpressionRewriter_Accessor(Enumerable.Empty <ParameterExpression>(), input.AllowOuterVariables);

                try
                {
                    Assert.AreSame(input.ConstantExpression, rewriter.VisitConstant(input.ConstantExpression));
                }
                catch (Exception e)
                {
                    Assert.IsTrue((input.Exception != null) && (input.Exception == e.GetType()));
                }
            }
        }
コード例 #2
0
        public void ExpressionRewriterConstantExercise()
        {
            foreach (var input in new []
            {
                new { Exception = typeof(NotSupportedException), AllowOuterVariables = false, ConstantExpression = Expression.Constant(Guid.NewGuid(), typeof(Guid)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(null, typeof(StringComparer)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant(null, typeof(StringComparer)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(Guid.NewGuid(), typeof(Guid)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant("abcd", typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant("abcd", typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant(null, typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(null, typeof(string)) },
                new { Exception = (Type)null, AllowOuterVariables = false, ConstantExpression = Expression.Constant(42, typeof(int)) },
                new { Exception = (Type)null, AllowOuterVariables = true, ConstantExpression = Expression.Constant(42, typeof(int)) },
            })
            {
                var rewriter = new ExpressionRewriter_Accessor(Enumerable.Empty<ParameterExpression>(), input.AllowOuterVariables);

                try
                {
                    Assert.AreSame(input.ConstantExpression, rewriter.VisitConstant(input.ConstantExpression));
                }
                catch (Exception e)
                {
                    Assert.IsTrue((input.Exception != null) && (input.Exception == e.GetType()));
                }
            }
        }
コード例 #3
0
        public void ExpressionRewriterParameterWithNoName()
        {
            var rewriter  = new ExpressionRewriter_Accessor(Enumerable.Empty <ParameterExpression>(), false);
            var parameter = Expression.Parameter(typeof(int));

            Assert.AreSame(parameter, rewriter.VisitParameter(parameter));
        }
コード例 #4
0
        public void ExpressionRewriterParameterWithNoName()
        {
            var rewriter = new ExpressionRewriter_Accessor(Enumerable.Empty<ParameterExpression>(), false);
            var parameter = Expression.Parameter(typeof(int));

            Assert.AreSame(parameter, rewriter.VisitParameter(parameter));
        }