public void VisitExtensionExpression() { var expression = new ReducibleExtensionExpression(Expression.Constant(0)); var result = FormattingExpressionVisitor.Format(expression); Assert.That(result, Is.EqualTo("Reducible(0)")); }
public void VisitUnknownNonExtensionExpression() { var expression = new UnknownExpression(typeof(object)); var result = FormattingExpressionVisitor.Format(expression); Assert.That(result, Is.EqualTo("[-1]")); }
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)")); }
/// <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 }
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)")); }
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)")); }
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 }