Skip to content

Commit af5ddac

Browse files
committed
Merge pull request #94 from ivaylokenov/development
Version 0.5.0
2 parents 4b428a7 + 6204452 commit af5ddac

File tree

175 files changed

+5908
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+5908
-231
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ publish/
136136

137137
# NuGet Packages
138138
*.nupkg
139+
!**/documentation/*.nupkg
139140
# The packages folder can be ignored because of Package Restore
140141
**/packages/*
141142
# except build/, which is used as an MSBuild target.

LICENSE

Lines changed: 674 additions & 21 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ MyWebApi
100100
.WithMessage("Some exception message");
101101
```
102102

103+
## License
104+
105+
Code by Ivaylo Kenov. Copyright 2015 Ivaylo Kenov.
106+
This library is licensed under [GNU General Public License v3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)) (full terms and conditions [here](https://www.gnu.org/licenses/gpl.html)). Basically:
107+
108+
- If you create software that uses GPL, you must license that software under GPL v3 (see [GPL FAQ](http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL))
109+
- If you create software that uses GPL, you must release your source code (see [GPL FAQ](http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL))
110+
- If you start with a GPL license, you cannot convert to another license
111+
- **You cannot include MyWebApi in a closed source distribution under this license**
112+
113+
If you have a really-coolish-and-nice open source or just closed source commercial project and you want to include MyWebApi in it, leave a question on the [issues page](https://github.com/ivaylokenov/MyWebApi/issues) and another license with the latest version of the library will be provided **free of charge** to you.
114+
103115
## Any questions, comments or additions?
104116

105117
Leave an issue on the [issues page](https://github.com/ivaylokenov/MyWebApi/issues) or send a [pull request](https://github.com/ivaylokenov/MyWebApi/pulls).

documentation/MyWebApi.0.5.0.nupkg

45.9 KB
Binary file not shown.

documentation/README.md

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
- [BadRequest result](#badrequest-result)
1818
- [JSON result](#json-result)
1919
- [StatusCode result](#statuscode-result)
20+
- [Redirect result](#redirect-result)
21+
- [Created result](#created-result)
2022
- [NotFound result](#notfound-result)
2123
- [Conflict result](#conflict-result)
2224
- [EmptyContent (void) result](#emptycontent-void-result)
25+
- [Null or Default result](#null-or-default-result)
2326
- [AndProvide... methods](#andprovide-methods)
2427

2528
### Controller instantiation
@@ -177,6 +180,12 @@ MyWebApi
177180
.ContainingModelStateErrorFor(m => m.ThirdProperty).EndingWith("message")
178181
.AndAlso() // error must contain the provided string
179182
.ContainingModelStateErrorFor(m => m.SecondProperty).Containing("ror mes");
183+
184+
// disable validation if needed
185+
MyWebApi
186+
.Controller<WebApiController>()
187+
.WithoutValidation()
188+
.Calling(c => c.SomeAction());
180189
```
181190

182191
[To top](#table-of-contents)
@@ -645,6 +654,221 @@ MyWebApi
645654
.StatusCode(HttpStatusCode.Created);
646655
```
647656

657+
[To top](#table-of-contents)
658+
659+
#### Redirect result
660+
661+
```c#
662+
// tests whether the action returns
663+
// RedirectResult or RedirectToRouteResult
664+
MyWebApi
665+
.Controller<WebApiController>()
666+
.Calling(c => c.SomeAction())
667+
.ShouldReturn()
668+
.Redirect();
669+
670+
// tests whether the action returns redirect result
671+
// with location provided as string
672+
MyWebApi
673+
.Controller<WebApiController>()
674+
.Calling(c => c.SomeAction())
675+
.ShouldReturn()
676+
.Redirect()
677+
.AtLocation("http://somehost.com/someuri/1?query=someQuery");
678+
679+
// tests whether the action returns redirect result
680+
// with location provided as URI
681+
MyWebApi
682+
.Controller<WebApiController>()
683+
.Calling(c => c.SomeAction())
684+
.ShouldReturn()
685+
.Redirect()
686+
.AtLocation(someUri);
687+
688+
// tests whether the action returns redirect result
689+
// with location provided as URI builder
690+
MyWebApi
691+
.Controller<WebApiController>()
692+
.Calling(c => c.SomeAction())
693+
.ShouldReturn()
694+
.Redirect()
695+
.AtLocation(
696+
location =>
697+
location
698+
.WithHost("somehost.com")
699+
.AndAlso() // AndAlso is not necessary
700+
.WithAbsolutePath("/someuri/1")
701+
.AndAlso()
702+
.WithPort(80)
703+
.AndAlso()
704+
.WithScheme("http")
705+
.AndAlso()
706+
.WithFragment(string.Empty)
707+
.AndAlso()
708+
.WithQuery("?query=Test"));
709+
```
710+
711+
[To top](#table-of-contents)
712+
713+
#### Created result
714+
715+
```c#
716+
// tests whether the action returns
717+
// CreatedNegotiatedContentResult<T>
718+
// or CreatedAtRouteNegotiatedContentResult<T>
719+
MyWebApi
720+
.Controller<WebApiController>()
721+
.Calling(c => c.SomeAction())
722+
.ShouldReturn()
723+
.Created();
724+
725+
// tests whether the action returns created result
726+
// with DefaultContentNegotiator
727+
MyWebApi
728+
.Controller<WebApiController>()
729+
.Calling(c => c.SomeAction())
730+
.ShouldReturn()
731+
.Created()
732+
.WithDefaultContentNegotiator();
733+
734+
// tests whether the action returns created result
735+
// with custom IContentNegotiator provided by instance
736+
MyWebApi
737+
.Controller<WebApiController>()
738+
.Calling(c => c.SomeAction())
739+
.ShouldReturn()
740+
.Created()
741+
.WithContentNegotiator(customContentNegotiator);
742+
743+
// tests whether the action returns created result
744+
// with custom IContentNegotiator provided by generic definition
745+
MyWebApi
746+
.Controller<WebApiController>()
747+
.Calling(c => c.SomeAction())
748+
.ShouldReturn()
749+
.Created()
750+
.WithContentNegotiatorOfType<CustomContentNegotiator>();
751+
752+
// tests whether the action returns created result
753+
// with location provided as string
754+
MyWebApi
755+
.Controller<WebApiController>()
756+
.Calling(c => c.SomeAction())
757+
.ShouldReturn()
758+
.Created()
759+
.AtLocation("http://somehost.com/someuri/1?query=someQuery");
760+
761+
// tests whether the action returns created result
762+
// with location provided as URI
763+
MyWebApi
764+
.Controller<WebApiController>()
765+
.Calling(c => c.SomeAction())
766+
.ShouldReturn()
767+
.Created()
768+
.AtLocation(someUri);
769+
770+
// tests whether the action returns created result
771+
// with location provided as URI builder
772+
MyWebApi
773+
.Controller<WebApiController>()
774+
.Calling(c => c.SomeAction())
775+
.ShouldReturn()
776+
.Created()
777+
.AtLocation(
778+
location =>
779+
location
780+
.WithHost("somehost.com")
781+
.AndAlso() // AndAlso is not necessary
782+
.WithAbsolutePath("/someuri/1")
783+
.AndAlso()
784+
.WithPort(80)
785+
.AndAlso()
786+
.WithScheme("http")
787+
.AndAlso()
788+
.WithFragment(string.Empty)
789+
.AndAlso()
790+
.WithQuery("?query=Test"));
791+
792+
// tests whether the action returns created result
793+
// with exactly the default media type formatters
794+
MyWebApi
795+
.Controller<WebApiController>()
796+
.Calling(c => c.SomeAction())
797+
.ShouldReturn()
798+
.Created()
799+
.ContainingDefaultFormatters();
800+
801+
// tests whether the action returns created result
802+
// containing media type formatter provided by instance
803+
MyWebApi
804+
.Controller<WebApiController>()
805+
.Calling(c => c.SomeAction())
806+
.ShouldReturn()
807+
.Created()
808+
.ContainingMediaTypeFormatter(someMediaTypeFormatter);
809+
810+
// tests whether the action returns created result
811+
// containing media type formatter provided by generic definition
812+
MyWebApi
813+
.Controller<WebApiController>()
814+
.Calling(c => c.SomeAction())
815+
.ShouldReturn()
816+
.Created()
817+
.ContainingMediaTypeFormatterOfType<JsonMediaTypeFormatter>();
818+
819+
// tests whether the action returns created result
820+
// with exactly the provided media type formatters
821+
MyWebApi
822+
.Controller<WebApiController>()
823+
.Calling(c => c.SomeAction())
824+
.ShouldReturn()
825+
.Created()
826+
.ContainingMediaTypeFormatters(someCollectionOfMediaTypeFormatters);
827+
828+
// tests whether the action returns created result
829+
// with exactly the provided media type formatters
830+
// by using params
831+
MyWebApi
832+
.Controller<WebApiController>()
833+
.Calling(c => c.SomeAction())
834+
.ShouldReturn()
835+
.Created()
836+
.ContainingMediaTypeFormatters(
837+
someMediaTypeFormatter,
838+
anotherMediaTypeFormatter,
839+
yetAnotherMediaTypeFormatter);
840+
841+
// tests whether the action returns created result
842+
// with exactly the provided media type formatters
843+
// by using formatters builder
844+
MyWebApi
845+
.Controller<WebApiController>()
846+
.Calling(c => c.SomeAction())
847+
.ShouldReturn()
848+
.Created()
849+
.ContainingMediaTypeFormatters(
850+
formatters =>
851+
formatters
852+
.ContainingMediaTypeFormatter(someMediaTypeFormatter)
853+
.AndAlso()
854+
.ContainingMediaTypeFormatterOfType<SomeMediaTypeFormatter>());
855+
856+
// tests whether the action returns created result
857+
// with different types of properties by using AndAlso()
858+
MyWebApi
859+
.Controller<WebApiController>()
860+
.Calling(c => c.CreatedActionWithCustomContentNegotiator())
861+
.ShouldReturn()
862+
.Created()
863+
.WithDefaultContentNegotiator()
864+
.AndAlso() // AndAlso is not necessary
865+
.AtLocation(someUri)
866+
.AndAlso()
867+
.ContainingMediaTypeFormatterOfType<SomeMediaTypeFormatter>();
868+
```
869+
870+
[To top](#table-of-contents)
871+
648872
#### NotFound result
649873
```c#
650874
// tests whether the action returns NotFoundResult
@@ -761,6 +985,25 @@ MyWebApi
761985

762986
[To top](#table-of-contents)
763987

988+
#### Null or Default result
989+
```c#
990+
// tests whether the action returns the default value of the return type
991+
MyWebApi
992+
.Controller<WebApiController>()
993+
.Calling(c => c.SomeAction())
994+
.ShouldReturn()
995+
.DefaultValue();
996+
997+
// tests whether the action returns null
998+
MyWebApi
999+
.Controller<WebApiController>()
1000+
.Calling(c => c.SomeAction())
1001+
.ShouldReturn()
1002+
.Null();
1003+
```
1004+
1005+
[To top](#table-of-contents)
1006+
7641007
### AndProvide... methods
7651008

7661009
You can get controller, action, action result and response model information where applicable by using AndProvide... methods.

documentation/nuget-readme.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
MyWebApi - ASP.NET Web API Fluent Testing Framework
2+
3+
MyWebApi is licensed under the GNU General Public Licence v3.
4+
Basically:
5+
- If you create software that uses GPL, you must license that software under GPL v3
6+
- If you create software that uses GPL, you must release your source code
7+
- If you start with a GPL license, you cannot convert to another license
8+
- You cannot include MyWebApi in a closed source distribution under this license
9+
10+
If you have a really-coolish-and-nice open source or
11+
just closed source commercial project and you want to
12+
include MyWebApi in it, leave a question on the issues page at
13+
https://github.com/ivaylokenov/MyWebApi/issues and another license
14+
with the latest version of the library will be provided free of charge to you.
15+
16+
Copyright (C) 2015 Ivaylo Kenov.
17+
18+
This program is free software: you can redistribute it and/or modify
19+
it under the terms of the GNU General Public License as published by
20+
the Free Software Foundation, either version 3 of the License, or
21+
(at your option) any later version.
22+
23+
This program is distributed in the hope that it will be useful,
24+
but WITHOUT ANY WARRANTY; without even the implied warranty of
25+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+
GNU General Public License for more details.
27+
28+
You should have received a copy of the GNU General Public License
29+
along with this program. If not, see http://www.gnu.org/licenses/.

src/MyWebApi.Tests/BuildersTests/ActionsTests/ShouldHaveModelStateTests.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
namespace MyWebApi.Tests.BuildersTests.ActionsTests
1+
// MyWebApi - ASP.NET Web API Fluent Testing Framework
2+
// Copyright (C) 2015 Ivaylo Kenov.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see http://www.gnu.org/licenses/.
16+
17+
namespace MyWebApi.Tests.BuildersTests.ActionsTests
218
{
319
using System;
420
using Exceptions;

src/MyWebApi.Tests/BuildersTests/ActionsTests/ShouldReturn/ShouldReturnBadRequestTests.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
namespace MyWebApi.Tests.BuildersTests.ActionsTests.ShouldReturn
1+
// MyWebApi - ASP.NET Web API Fluent Testing Framework
2+
// Copyright (C) 2015 Ivaylo Kenov.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see http://www.gnu.org/licenses/.
16+
17+
namespace MyWebApi.Tests.BuildersTests.ActionsTests.ShouldReturn
218
{
319
using Exceptions;
420
using NUnit.Framework;

src/MyWebApi.Tests/BuildersTests/ActionsTests/ShouldReturn/ShouldReturnConflictTests.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
namespace MyWebApi.Tests.BuildersTests.ActionsTests.ShouldReturn
1+
// MyWebApi - ASP.NET Web API Fluent Testing Framework
2+
// Copyright (C) 2015 Ivaylo Kenov.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see http://www.gnu.org/licenses/.
16+
17+
namespace MyWebApi.Tests.BuildersTests.ActionsTests.ShouldReturn
218
{
319
using Exceptions;
420
using NUnit.Framework;

0 commit comments

Comments
 (0)