@@ -36,32 +36,32 @@ public void Correctly_parse_equality_comparison_with_property_operand()
36
36
}
37
37
38
38
[ Test ]
39
- public void Correctly_parse_equality_comparison_with_property_operands ( )
39
+ public void Correctly_parse_equality_comparison_with_two_property_operands ( )
40
40
{
41
- Expression < Func < PostViewModel , bool > > func = post => post . Title == post . Slug ;
41
+ Expression < Func < PostViewModel , bool > > func = post =>
42
+ post . Title == post . Slug ;
42
43
ExpressionInspector sut = new ExpressionInspector ( ) ;
43
44
var actual = sut . Inspect ( func ) ;
44
45
Assert . AreEqual ( "post => (post.Title == post.Slug)" , actual ) ;
45
46
}
46
47
47
48
[ Test ]
48
- public void Correctly_parse_inequality_comparison ( )
49
+ public void Correctly_parse_equality_comparison_with_captured_constant_operand ( )
49
50
{
50
- Expression < Func < int , bool > > func = number => number != 5 ;
51
+ const int Number = 5 ;
52
+ Expression < Func < int , bool > > func = number => number == Number ;
51
53
ExpressionInspector sut = new ExpressionInspector ( ) ;
52
54
var actual = sut . Inspect ( func ) ;
53
- Assert . AreEqual ( "number => (number != 5)" , actual ) ;
55
+ Assert . AreEqual ( string . Concat ( "number => (number == " , Number , ")" ) , actual ) ;
54
56
}
55
57
56
58
[ Test ]
57
- public void Correctly_parse_equality_comparison_with_captured_constant_operand ( )
59
+ public void Correctly_parse_inequality_comparison ( )
58
60
{
59
- const int Number = 5 ;
60
- Expression < Func < int , bool > > func = number => number == Number ;
61
+ Expression < Func < int , bool > > func = number => number != 5 ;
61
62
ExpressionInspector sut = new ExpressionInspector ( ) ;
62
63
var actual = sut . Inspect ( func ) ;
63
- Assert . AreEqual (
64
- string . Concat ( "number => (number == " , Number , ")" ) , actual ) ;
64
+ Assert . AreEqual ( "number => (number != 5)" , actual ) ;
65
65
}
66
66
67
67
[ Test ]
@@ -73,6 +73,25 @@ public void Correctly_parse_relational_comparison()
73
73
Assert . AreEqual ( "number => (number < 5)" , actual ) ;
74
74
}
75
75
76
+ [ Test ]
77
+ public void Correctly_parse_expression_whose_source_text_contains_parentheses ( )
78
+ {
79
+ Expression < Func < PostViewModel , bool > > func = post => post . Title . Contains ( "" ) ;
80
+ ExpressionInspector sut = new ExpressionInspector ( ) ;
81
+ var actual = sut . Inspect ( func ) ;
82
+ Assert . AreEqual ( "post => post.Title.Contains(\" \" )" , actual ) ;
83
+ }
84
+
85
+ [ Test ]
86
+ public void Correctly_parse_null_coalescing_operator ( )
87
+ {
88
+ Expression < Func < string , bool > > func =
89
+ text => text == ( "" ?? "a" ) ;
90
+ ExpressionInspector sut = new ExpressionInspector ( ) ;
91
+ var actual = sut . Inspect ( func ) ;
92
+ Assert . AreEqual ( "text => (text == (\" \" ?? \" a\" ))" , actual ) ;
93
+ }
94
+
76
95
[ Test ]
77
96
public void Correctly_parse_conditional_or_operator ( )
78
97
{
@@ -90,10 +109,10 @@ public void Correctly_parse_two_conditional_or_operators()
90
109
text => text == "any" || text . Length == 3 || text . Length == 9 ;
91
110
ExpressionInspector sut = new ExpressionInspector ( ) ;
92
111
var actual = sut . Inspect ( func ) ;
93
- Assert . AreEqual ( "text => (((text == \" any\" ) || (text.Length == 3)) || (text.Length == 9))" , actual ) ;
112
+ Assert . AreEqual (
113
+ "text => (((text == \" any\" ) || (text.Length == 3)) || (text.Length == 9))" , actual ) ;
94
114
}
95
115
96
-
97
116
[ Test ]
98
117
public void Correctly_parse_conditional_and_operator ( )
99
118
{
@@ -114,7 +133,6 @@ public void Correctly_parse_logical_and_operator()
114
133
Assert . AreEqual ( "text => ((text == \" any\" ) & (text.Length == 3))" , actual ) ;
115
134
}
116
135
117
-
118
136
[ Test ]
119
137
public void Correctly_parse_logical_or_operator ( )
120
138
{
@@ -125,16 +143,6 @@ public void Correctly_parse_logical_or_operator()
125
143
Assert . AreEqual ( "text => ((text == \" any\" ) | (text.Length == 3))" , actual ) ;
126
144
}
127
145
128
- [ Test ]
129
- public void Correctly_parse_null_coalescing_operator ( )
130
- {
131
- Expression < Func < string , bool > > func =
132
- text => text == ( "" ?? "a" ) ;
133
- ExpressionInspector sut = new ExpressionInspector ( ) ;
134
- var actual = sut . Inspect ( func ) ;
135
- Assert . AreEqual ( "text => (text == (\" \" ?? \" a\" ))" , actual ) ;
136
- }
137
-
138
146
[ Test ]
139
147
public void Not_mistake_property_called_OrElse_for_conditional_or_operator ( )
140
148
{
@@ -145,15 +153,6 @@ public void Not_mistake_property_called_OrElse_for_conditional_or_operator()
145
153
Assert . AreEqual ( "post => ((post.Title == \" \" ) || (post.OrElse == \" \" ))" , actual ) ;
146
154
}
147
155
148
- [ Test ]
149
- public void Correctly_parse_expression_whose_source_text_contains_parentheses ( )
150
- {
151
- Expression < Func < PostViewModel , bool > > func = post => post . Title . Contains ( "" ) ;
152
- ExpressionInspector sut = new ExpressionInspector ( ) ;
153
- var actual = sut . Inspect ( func ) ;
154
- Assert . AreEqual ( "post => post.Title.Contains(\" \" )" , actual ) ;
155
- }
156
-
157
156
[ Test ]
158
157
public void Correctly_parse_logical_xor_operator ( )
159
158
{
0 commit comments