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()
5353 }
5454
5555 [ Test ]
56- public void Check_for_non_existent_temp_data_property ( )
56+ public void Check_for_unexpected_non_existent_temp_data_property ( )
5757 {
5858 const string key = "" ;
5959
@@ -136,7 +136,7 @@ public void Check_for_existent_temp_data_property_and_check_value_using_invalid_
136136 }
137137
138138 [ 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 ( )
140140 {
141141 const string key = "" ;
142142
@@ -146,5 +146,25 @@ public void Check_for_non_existent_temp_data_property_when_supplied_with_predica
146146 Assert . That ( exception . Message , Is . EqualTo ( string . Format (
147147 "Expected TempData to have a non-null value with key \" {0}\" , but none found." , key ) ) ) ;
148148 }
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+ }
149169 }
150170}
Original file line number Diff line number Diff line change @@ -104,5 +104,19 @@ public static TempDataResultTest ShouldHaveTempDataProperty<TValue>(this Control
104104
105105 return new TempDataResultTest ( controller ) ;
106106 }
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+
107121 }
108122}
You can’t perform that action at this time.
0 commit comments