@@ -61,6 +61,8 @@ MyWebApi
6161 .Controller (myWebApiControllerInstance );
6262```
6363
64+ [ To top] ( #table-of-contents )
65+
6466### Authenticated user
6567
6668``` c#
@@ -87,6 +89,8 @@ MyWebApi
8789 .InRoles (" Moderator" , " Administrator" )); // or InRole("Moderator")
8890```
8991
92+ [ To top] ( #table-of-contents )
93+
9094### Calling actions
9195
9296You can call any action using lambda expression. All parameter values will be resolved and model state validation will be performed on them:
@@ -108,6 +112,8 @@ MyWebApi
108112 .CallingAsync (c => c .SomeActionAsync ());
109113```
110114
115+ [ To top] ( #table-of-contents )
116+
111117### Model state validation
112118
113119You can test whether model state is valid/invalid or contains any specific error:
@@ -173,6 +179,8 @@ MyWebApi
173179 .ContainingModelStateErrorFor (m => m .SecondProperty ).Containing (" ror mes" );
174180```
175181
182+ [ To top] ( #table-of-contents )
183+
176184### Catching thrown exceptions
177185
178186You can test whether action throws exception:
@@ -229,6 +237,8 @@ MyWebApi
229237 .WithStatusCode (HttpStatusCode .NotFound );
230238```
231239
240+ [ To top] ( #table-of-contents )
241+
232242### Action results
233243
234244You can test for specific return values or the default IHttpActionResult types:
@@ -294,6 +304,8 @@ MyWebApi
294304 .ShouldReturn ();
295305```
296306
307+ [ To top] ( #table-of-contents )
308+
297309#### Ok result
298310
299311``` c#
@@ -365,6 +377,8 @@ MyWebApi
365377 .ContainingNoModelStateErrorFor (m => m .AnotherProperty );
366378```
367379
380+ [ To top] ( #table-of-contents )
381+
368382#### Unauthorized result
369383
370384``` c#
@@ -467,6 +481,8 @@ MyWebApi
467481 .ContainingHeader (header => header .WithScheme (AuthenticationScheme .Basic )));
468482```
469483
484+ [ To top] ( #table-of-contents )
485+
470486#### BadRequest result
471487
472488``` c#
@@ -553,6 +569,8 @@ MyWebApi
553569 .ContainingNoModelStateErrorFor (m => m .NonRequiredString );
554570```
555571
572+ [ To top] ( #table-of-contents )
573+
556574#### JSON result
557575``` c#
558576// tests whether the action returns JSON
@@ -606,6 +624,8 @@ MyWebApi
606624 .WithConstructorHandling (ConstructorHandling .Default ));
607625```
608626
627+ [ To top] ( #table-of-contents )
628+
609629#### StatusCode result
610630
611631``` c#
@@ -635,6 +655,8 @@ MyWebApi
635655 .NotFound ();
636656```
637657
658+ [ To top] ( #table-of-contents )
659+
638660#### Conflict result
639661``` c#
640662// tests whether the action returns ConflictResult
@@ -645,6 +667,8 @@ MyWebApi
645667 .Conflict ();
646668```
647669
670+ [ To top] ( #table-of-contents )
671+
648672#### InternalServerError result
649673``` c#
650674// tests whether the action returns
@@ -723,6 +747,8 @@ MyWebApi
723747 .WithMessage ().Containing (" n m" );
724748```
725749
750+ [ To top] ( #table-of-contents )
751+
726752#### EmptyContent (void) result
727753``` c#
728754// tests whether the action does not return anything (204 No Content)
@@ -733,6 +759,8 @@ MyWebApi
733759 .ShouldReturnEmpty ();
734760```
735761
762+ [ To top] ( #table-of-contents )
763+
736764### AndProvide... methods
737765
738766You can get controller, action, action result and response model information where applicable by using AndProvide... methods.
@@ -785,4 +813,6 @@ MyWebApi
785813 .ShouldThrow ()
786814 .Exception ()
787815 .AndProvideTheCaughtException ();
788- ```
816+ ```
817+
818+ [ To top] ( #table-of-contents )
0 commit comments