@@ -71,11 +71,42 @@ public void Correctly_parse_relational_comparison()
71
71
var actual = sut . Inspect ( func ) ;
72
72
Assert . AreEqual ( "number => number < 5" , actual ) ;
73
73
}
74
+
75
+ [ Test ]
76
+ public void Correctly_parse_conditional_or_operator ( )
77
+ {
78
+ Expression < Func < string , bool > > func =
79
+ text => text == "any" || text . Length == 3 ;
80
+ ExpressionInspector sut = new ExpressionInspector ( ) ;
81
+ var actual = sut . Inspect ( func ) ;
82
+ Assert . AreEqual ( "text => text == \" any\" || text.Length == 3" , actual ) ;
83
+ }
84
+
85
+ public void Correctly_parse_two_conditional_or_operators ( )
86
+ {
87
+ Expression < Func < string , bool > > func =
88
+ text => text == "any" || text . Length == 3 || text . Length == 9 ;
89
+ ExpressionInspector sut = new ExpressionInspector ( ) ;
90
+ var actual = sut . Inspect ( func ) ;
91
+ Assert . AreEqual ( "text => text == \" any\" || text.Length == 3 || text.Length == 9" , actual ) ;
92
+ }
93
+
94
+ [ Test ]
95
+ public void Not_mistake_property_called_OrElse_for_conditional_or_operator ( )
96
+ {
97
+ Expression < Func < PostViewModel , bool > > func =
98
+ post => post . Title == "" || post . OrElse == "" ;
99
+ ExpressionInspector sut = new ExpressionInspector ( ) ;
100
+ var actual = sut . Inspect ( func ) ;
101
+ Assert . AreEqual ( "post => post.Title == \" \" || post.OrElse == \" \" " , actual ) ;
102
+ }
74
103
}
75
104
76
105
public class PostViewModel
77
106
{
78
107
public string Title { get ; set ; }
79
108
public string Slug { get ; set ; }
109
+
110
+ public string OrElse { get ; set ; }
80
111
}
81
112
}
0 commit comments