File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
TestStack.FluentMVCTesting.Tests
TestStack.FluentMvcTesting Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public void Check_for_existent_temp_data_property()
53
53
}
54
54
55
55
[ Test ]
56
- public void Check_for_non_existent_temp_data_property ( )
56
+ public void Check_for_unexpected_non_existent_temp_data_property ( )
57
57
{
58
58
const string key = "" ;
59
59
@@ -136,7 +136,7 @@ public void Check_for_existent_temp_data_property_and_check_value_using_invalid_
136
136
}
137
137
138
138
[ Test ]
139
- public void Check_for_non_existent_temp_data_property_when_supplied_with_predicate ( )
139
+ public void Check_for_unexpected_non_existent_temp_data_property_when_supplied_with_predicate ( )
140
140
{
141
141
const string key = "" ;
142
142
@@ -146,5 +146,25 @@ public void Check_for_non_existent_temp_data_property_when_supplied_with_predica
146
146
Assert . That ( exception . Message , Is . EqualTo ( string . Format (
147
147
"Expected TempData to have a non-null value with key \" {0}\" , but none found." , key ) ) ) ;
148
148
}
149
+
150
+ [ Test ]
151
+ public void Check_for_non_existent_temp_data_property ( )
152
+ {
153
+ _controller
154
+ . ShouldNotHaveTempDataProperty ( "" ) ;
155
+ }
156
+
157
+ [ Test ]
158
+ public void Check_for_unexpected_existent_temp_data_property ( )
159
+ {
160
+ const string Key = "" ;
161
+ _controller . TempData [ Key ] = "" ;
162
+
163
+ var exception = Assert . Throws < TempDataAssertionException > ( ( ) =>
164
+ _controller . ShouldNotHaveTempDataProperty ( Key ) ) ;
165
+
166
+ Assert . That ( exception . Message , Is . EqualTo ( string . Format (
167
+ "Expected TempData to have no value with key \" {0}\" , but found one." , Key ) ) ) ;
168
+ }
149
169
}
150
170
}
Original file line number Diff line number Diff line change @@ -104,5 +104,19 @@ public static TempDataResultTest ShouldHaveTempDataProperty<TValue>(this Control
104
104
105
105
return new TempDataResultTest ( controller ) ;
106
106
}
107
+
108
+ public static TempDataResultTest ShouldNotHaveTempDataProperty ( this Controller controller , string key )
109
+ {
110
+ var actual = controller . TempData [ key ] ;
111
+
112
+ if ( actual != null )
113
+ {
114
+ throw new TempDataAssertionException ( string . Format (
115
+ "Expected TempData to have no value with key \" {0}\" , but found one." , key ) ) ;
116
+ }
117
+
118
+ return new TempDataResultTest ( controller ) ;
119
+ }
120
+
107
121
}
108
122
}
You can’t perform that action at this time.
0 commit comments