@@ -187,7 +187,7 @@ public void WithViewData_GivenUnexpectedKey_ShouldFail()
187
187
}
188
188
189
189
[ Test ]
190
- public void Model_GivenExpectedValue_ShouldPass ( )
190
+ public void Model_ForViewResult_GivenExpectedValue_ShouldPass ( )
191
191
{
192
192
ActionResult result = new ViewResult
193
193
{
@@ -198,7 +198,18 @@ public void Model_GivenExpectedValue_ShouldPass()
198
198
}
199
199
200
200
[ Test ]
201
- public void Model_GivenUnexpectedValue_ShouldFail ( )
201
+ public void Model_ForPartialViewResult_GivenExpectedValue_ShouldPass ( )
202
+ {
203
+ ActionResult result = new PartialViewResult
204
+ {
205
+ ViewData = new ViewDataDictionary ( "hello" )
206
+ } ;
207
+
208
+ result . Should ( ) . BePartialViewResult ( ) . Model . Should ( ) . Be ( "hello" ) ;
209
+ }
210
+
211
+ [ Test ]
212
+ public void Model_ForViewResult_GivenUnexpectedValue_ShouldFail ( )
202
213
{
203
214
ActionResult result = new ViewResult
204
215
{
@@ -210,7 +221,19 @@ public void Model_GivenUnexpectedValue_ShouldFail()
210
221
}
211
222
212
223
[ Test ]
213
- public void ModelAs_GivenExpectedValue_ShouldPass ( )
224
+ public void Model_ForPartialViewResult_GivenUnexpectedValue_ShouldFail ( )
225
+ {
226
+ ActionResult result = new PartialViewResult
227
+ {
228
+ ViewData = new ViewDataDictionary ( "hello" )
229
+ } ;
230
+
231
+ Action a = ( ) => result . Should ( ) . BePartialViewResult ( ) . Model . Should ( ) . Be ( "xyx" ) ;
232
+ a . ShouldThrow < Exception > ( ) ;
233
+ }
234
+
235
+ [ Test ]
236
+ public void ModelAs_ForViewResult_GivenExpectedValue_ShouldPass ( )
214
237
{
215
238
ActionResult result = new ViewResult
216
239
{
@@ -221,7 +244,18 @@ public void ModelAs_GivenExpectedValue_ShouldPass()
221
244
}
222
245
223
246
[ Test ]
224
- public void ModelAs_GivenUnexpectedValue_ShouldFail ( )
247
+ public void ModelAs_ForPartialViewResult_GivenExpectedValue_ShouldPass ( )
248
+ {
249
+ ActionResult result = new PartialViewResult
250
+ {
251
+ ViewData = new ViewDataDictionary ( "hello" )
252
+ } ;
253
+
254
+ result . Should ( ) . BePartialViewResult ( ) . ModelAs < string > ( ) . Should ( ) . Be ( "hello" ) ;
255
+ }
256
+
257
+ [ Test ]
258
+ public void ModelAs_ForViewResult_GivenUnexpectedValue_ShouldFail ( )
225
259
{
226
260
ActionResult result = new ViewResult
227
261
{
@@ -233,7 +267,19 @@ public void ModelAs_GivenUnexpectedValue_ShouldFail()
233
267
}
234
268
235
269
[ Test ]
236
- public void ModelAs_GivenWrongType_ShouldFail ( )
270
+ public void ModelAs_ForPartialViewResult_GivenUnexpectedValue_ShouldFail ( )
271
+ {
272
+ ActionResult result = new PartialViewResult
273
+ {
274
+ ViewData = new ViewDataDictionary ( "hello" )
275
+ } ;
276
+
277
+ Action a = ( ) => result . Should ( ) . BePartialViewResult ( ) . ModelAs < string > ( ) . Should ( ) . Be ( "xyx" ) ;
278
+ a . ShouldThrow < Exception > ( ) ;
279
+ }
280
+
281
+ [ Test ]
282
+ public void ModelAs_ForViewResult_GivenWrongType_ShouldFail ( )
237
283
{
238
284
ActionResult result = new ViewResult
239
285
{
@@ -245,7 +291,19 @@ public void ModelAs_GivenWrongType_ShouldFail()
245
291
}
246
292
247
293
[ Test ]
248
- public void ModelAs_Null_ShouldFail ( )
294
+ public void ModelAs_ForPartialViewResult_GivenWrongType_ShouldFail ( )
295
+ {
296
+ ActionResult result = new PartialViewResult
297
+ {
298
+ ViewData = new ViewDataDictionary ( "hello" )
299
+ } ;
300
+
301
+ Action a = ( ) => result . Should ( ) . BePartialViewResult ( ) . ModelAs < int > ( ) . Should ( ) . Be ( 2 ) ;
302
+ a . ShouldThrow < Exception > ( ) ;
303
+ }
304
+
305
+ [ Test ]
306
+ public void ModelAs_ForViewResult_Null_ShouldFail ( )
249
307
{
250
308
ActionResult result = new ViewResult ( ) ;
251
309
string failureMessage = FailureMessageHelper . Format ( FailureMessages . ViewResultBase_NullModel , typeof ( Object ) . Name ) ;
@@ -256,6 +314,18 @@ public void ModelAs_Null_ShouldFail()
256
314
. WithMessage ( failureMessage ) ;
257
315
}
258
316
317
+ [ Test ]
318
+ public void ModelAs_ForPartialViewResult_Null_ShouldFail ( )
319
+ {
320
+ ActionResult result = new PartialViewResult ( ) ;
321
+ string failureMessage = FailureMessageHelper . Format ( FailureMessages . ViewResultBase_NullModel , typeof ( Object ) . Name ) ;
322
+
323
+ Action a = ( ) => result . Should ( ) . BePartialViewResult ( ) . ModelAs < Object > ( ) ;
324
+
325
+ a . ShouldThrow < Exception > ( )
326
+ . WithMessage ( failureMessage ) ;
327
+ }
328
+
259
329
[ Test ]
260
330
public void WithDefaultViewName_GivenExpectedValue_ShouldPass ( )
261
331
{
0 commit comments