コード例 #1
0
        public void VisitExtensionExpression()
        {
            var expression = new ReducibleExtensionExpression(Expression.Constant(0));
            var result     = FormattingExpressionVisitor.Format(expression);

            Assert.That(result, Is.EqualTo("Reducible(0)"));
        }
コード例 #2
0
        public void VisitUnknownNonExtensionExpression()
        {
            var expression = new UnknownExpression(typeof(object));
            var result     = FormattingExpressionVisitor.Format(expression);

            Assert.That(result, Is.EqualTo("[-1]"));
        }
コード例 #3
0
        public void OrdinaryExpression()
        {
            var expression          = Expression.MakeBinary(ExpressionType.GreaterThan, Expression.Constant(1), Expression.Constant(2));
            var formattedExpression = FormattingExpressionVisitor.Format(expression);

            Assert.That(formattedExpression, Is.EqualTo("(1 > 2)"));
        }
コード例 #4
0
        /// <summary>
        /// Builds a string from the <paramref name="expression"/> tree, including .NET 3.5.
        /// </summary>
        public static string BuildString(this Expression expression)
        {
#if !NET_3_5
            return(expression.ToString());
#else
            return(FormattingExpressionVisitor.Format(expression));
#endif
        }
コード例 #5
0
        public void QuerySourceReferenceExpression()
        {
            var referencedClause = ExpressionHelper.CreateMainFromClause_Int("i", typeof(int), ExpressionHelper.CreateQueryable <Cook>());

            var expression          = Expression.MakeBinary(ExpressionType.GreaterThan, new QuerySourceReferenceExpression(referencedClause), Expression.Constant(2));
            var formattedExpression = FormattingExpressionVisitor.Format(expression);

            Assert.That(formattedExpression, Is.EqualTo("([i] > 2)"));
        }
コード例 #6
0
        public void SubQueryExpression()
        {
            var queryExpression = ExpressionHelper.MakeExpression(() => (from s in ExpressionHelper.CreateQueryable <Cook> () select s).Count());
            var subQueryModel   = ExpressionHelper.ParseQuery(queryExpression);

            var expression          = Expression.MakeBinary(ExpressionType.GreaterThan, new SubQueryExpression(subQueryModel), Expression.Constant(2));
            var formattedExpression = FormattingExpressionVisitor.Format(expression);

            Assert.That(formattedExpression, Is.EqualTo("({TestQueryable<Cook>() => Count()} > 2)"));
        }
コード例 #7
0
        public void ToString_Nested()
        {
            var expression = Expression.Not(_expression);

#if !NET_3_5
            var result = expression.ToString();
            Assert.That(result, Is.EqualTo("Not(VBCompareString((\"string1\" == \"string2\"), True))"));
#else
            var result = FormattingExpressionVisitor.Format(expression);
            Assert.That(result, Is.EqualTo("Not(VBCompareString((\"string1\" = \"string2\"), True))"));
#endif
        }