Skip to content

Commit 8c40d33

Browse files
committed
Merge pull request #79 from ivaylokenov/development
Version 0.4
2 parents 9708bd8 + 89c7ce0 commit 8c40d33

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

documentation/README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@
33

44
## Full list of available features
55

6+
### Table of contents
7+
8+
- [Controller instantiation](#controller-instantiation)
9+
- [Authenticated user](#authenticated-user)
10+
- [Calling actions](#calling-actions)
11+
- [Model state validation](#model-state-validation)
12+
- [Catching thrown exceptions](#catching-thrown-exceptions)
13+
- [Generic result](#generic-result)
14+
- [Any result](#any-result)
15+
- [Ok result](#ok-result)
16+
- [Unauthorized result](#unauthorized-result)
17+
- [BadRequest result](#badrequest-result)
18+
- [JSON result](#json-result)
19+
- [StatusCode result](#statuscode-result)
20+
- [NotFound result](#notfound-result)
21+
- [Conflict result](#conflict-result)
22+
- [EmptyContent (void) result](#emptycontent-void-result)
23+
- [AndProvide... methods](#andprovide-methods)
24+
625
### Controller instantiation
726

827
You have a couple of options from which you can setup the controller you want to test. The framework gives you static `MyWebApi` class from which the test builder starts:
@@ -42,6 +61,8 @@ MyWebApi
4261
.Controller(myWebApiControllerInstance);
4362
```
4463

64+
[To top](#table-of-contents)
65+
4566
### Authenticated user
4667

4768
```c#
@@ -68,6 +89,8 @@ MyWebApi
6889
.InRoles("Moderator", "Administrator")); // or InRole("Moderator")
6990
```
7091

92+
[To top](#table-of-contents)
93+
7194
### Calling actions
7295

7396
You can call any action using lambda expression. All parameter values will be resolved and model state validation will be performed on them:
@@ -89,6 +112,8 @@ MyWebApi
89112
.CallingAsync(c => c.SomeActionAsync());
90113
```
91114

115+
[To top](#table-of-contents)
116+
92117
### Model state validation
93118

94119
You can test whether model state is valid/invalid or contains any specific error:
@@ -154,6 +179,8 @@ MyWebApi
154179
.ContainingModelStateErrorFor(m => m.SecondProperty).Containing("ror mes");
155180
```
156181

182+
[To top](#table-of-contents)
183+
157184
### Catching thrown exceptions
158185

159186
You can test whether action throws exception:
@@ -210,6 +237,8 @@ MyWebApi
210237
.WithStatusCode(HttpStatusCode.NotFound);
211238
```
212239

240+
[To top](#table-of-contents)
241+
213242
### Action results
214243

215244
You can test for specific return values or the default IHttpActionResult types:
@@ -275,6 +304,8 @@ MyWebApi
275304
.ShouldReturn();
276305
```
277306

307+
[To top](#table-of-contents)
308+
278309
#### Ok result
279310

280311
```c#
@@ -346,6 +377,8 @@ MyWebApi
346377
.ContainingNoModelStateErrorFor(m => m.AnotherProperty);
347378
```
348379

380+
[To top](#table-of-contents)
381+
349382
#### Unauthorized result
350383

351384
```c#
@@ -448,6 +481,8 @@ MyWebApi
448481
.ContainingHeader(header => header.WithScheme(AuthenticationScheme.Basic)));
449482
```
450483

484+
[To top](#table-of-contents)
485+
451486
#### BadRequest result
452487

453488
```c#
@@ -534,6 +569,8 @@ MyWebApi
534569
.ContainingNoModelStateErrorFor(m => m.NonRequiredString);
535570
```
536571

572+
[To top](#table-of-contents)
573+
537574
#### JSON result
538575
```c#
539576
// tests whether the action returns JSON
@@ -587,6 +624,8 @@ MyWebApi
587624
.WithConstructorHandling(ConstructorHandling.Default));
588625
```
589626

627+
[To top](#table-of-contents)
628+
590629
#### StatusCode result
591630

592631
```c#
@@ -616,6 +655,8 @@ MyWebApi
616655
.NotFound();
617656
```
618657

658+
[To top](#table-of-contents)
659+
619660
#### Conflict result
620661
```c#
621662
// tests whether the action returns ConflictResult
@@ -626,6 +667,8 @@ MyWebApi
626667
.Conflict();
627668
```
628669

670+
[To top](#table-of-contents)
671+
629672
#### InternalServerError result
630673
```c#
631674
// tests whether the action returns
@@ -704,6 +747,8 @@ MyWebApi
704747
.WithMessage().Containing("n m");
705748
```
706749

750+
[To top](#table-of-contents)
751+
707752
#### EmptyContent (void) result
708753
```c#
709754
// tests whether the action does not return anything (204 No Content)
@@ -714,6 +759,8 @@ MyWebApi
714759
.ShouldReturnEmpty();
715760
```
716761

762+
[To top](#table-of-contents)
763+
717764
### AndProvide... methods
718765

719766
You can get controller, action, action result and response model information where applicable by using AndProvide... methods.
@@ -766,4 +813,6 @@ MyWebApi
766813
.ShouldThrow()
767814
.Exception()
768815
.AndProvideTheCaughtException();
769-
```
816+
```
817+
818+
[To top](#table-of-contents)

documentation/nuget-logo.png

2.11 KB
Loading

0 commit comments

Comments
 (0)