Skip to content

Commit 175777a

Browse files
authored
Merge pull request #231 from ivaylokenov/development
Moved documentation into master branch
2 parents eb2cbd5 + 708a544 commit 175777a

File tree

1,566 files changed

+430075
-23703
lines changed

Some content is hidden

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

1,566 files changed

+430075
-23703
lines changed

MyTested.AspNetCore.Mvc.sln

Lines changed: 221 additions & 1 deletion
Large diffs are not rendered by default.

README.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,33 @@ MyTested.AspNetCore.Mvc is a unit testing library (currently in preview version)
77

88
## Getting started
99

10-
It is strongly advised to start with the [tutorial](http://docs.mytestedasp.net/tutorial/intro.html) (coming soon) in order to get familiar with MyTested.AspNetCore.Mvc. Additionally, you may see the [testing guide](http://docs.mytestedasp.net/guide/intro.html) (coming soon) or the [API reference](http://docs.mytestedasp.net/api/index.html) for full list of available features. MyTested.AspNetCore.Mvc is 100% covered by [more than 1500 unit tests](https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/tree/master/test/) and should work correctly. Almost all items in the [issues page](https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/issues) are expected future features and enhancements.
10+
It is strongly advised to start with the [tutorial](http://docs.mytestedasp.net/tutorial/intro.html) (coming soon) in order to get familiar with MyTested.AspNetCore.Mvc. Additionally, you may see the [testing guide](http://docs.mytestedasp.net/guide/intro.html) (coming soon) or the [API reference](http://docs.mytestedasp.net/api/index.html) for full list of available features. MyTested.AspNetCore.Mvc is 100% covered by [more than 1800 unit tests](https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/tree/master/test/) and should work correctly. Almost all items in the [issues page](https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/issues) are expected future features and enhancements.
1111

1212
## Installation
1313

1414
You can install this library using NuGet into your test project (or reference it directly in your `project.json` file). Currently MyTested.AspNetCore.Mvc works with ASP.NET Core MVC 1.0.0.
1515

16-
Install-Package MyTested.AspNetCore.Mvc -Pre
16+
Install-Package MyTested.AspNetCore.Mvc.Universe
17+
18+
This package will include all available assertion methods in your test project, including ones for authentication, database, session, caching and more. If you want only the MVC related features, install `MyTested.AspNetCore.Mvc`. Additionally, if you prefer, you can be more specific by including only some of the packages:
19+
20+
- `MyTested.AspNetCore.Mvc.Controllers` - contains setup and assertion methods for controllers
21+
- `MyTested.AspNetCore.Mvc.Routing` - contains setup and assertion methods for routes
22+
- `MyTested.AspNetCore.Mvc.Core` - contains setup and assertion methods for MVC core features
23+
- `MyTested.AspNetCore.Mvc.TempData` - contains setup and assertion methods for `ITempDataDictionary`
24+
- `MyTested.AspNetCore.Mvc.ViewData` - contains assertion methods for `ViewDataDictionary` and dynamic `ViewBag`
25+
- `MyTested.AspNetCore.Mvc.ViewActionResults` - contains setup and assertion methods for view action results
26+
- `MyTested.AspNetCore.Mvc.ViewComponents` - contains setup and assertion methods for view components
27+
- `MyTested.AspNetCore.Mvc.ViewFeatures` - contains setup and assertion methods for MVC view features
28+
- `MyTested.AspNetCore.Mvc.Http` - contains setup and assertion methods for HTTP context, request and response
29+
- `MyTested.AspNetCore.Mvc.Authentication` - contains setup methods for `ClaimsPrincipal`
30+
- `MyTested.AspNetCore.Mvc.ModelState` - contains setup and assertion methods for `ModelStateDictionary` validations
31+
- `MyTested.AspNetCore.Mvc.DataAnnotations` - contains setup and assertion methods for data annotation validations
32+
- `MyTested.AspNetCore.Mvc.EntityFrameworkCore` - contains setup and assertion methods for `DbContext`
33+
- `MyTested.AspNetCore.Mvc.DependencyInjection` - contains setup methods for dependency injection services
34+
- `MyTested.AspNetCore.Mvc.Caching` - contains setup and assertion methods for `IMemoryCache`
35+
- `MyTested.AspNetCore.Mvc.Session` - contains setup and assertion methods for `ISession`
36+
- `MyTested.AspNetCore.Mvc.Options` - contains setup and assertion methods for `IOptions`
1737

1838
After the downloading is complete, just add `using MyTested.AspNetCore.Mvc;` to your source code and you are ready to test in the most elegant and developer friendly way.
1939

@@ -32,7 +52,7 @@ Make sure to check out the [tutorial](http://docs.mytestedasp.net/tutorial/intro
3252

3353
You can also check out the [provided samples](https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/tree/master/samples) for real-life ASP.NET Core MVC application testing.
3454

35-
First we need to create a `TestStartup` class in the root of the test project in order to register the dependency injection services. The easiest way is to inherit from the web project's `Startup` class and replace some of the services with mocked ones by using the provided extension methods.
55+
The easiest way to start with MyTested.AspNetCore.Mvc is to create a `TestStartup` class at the root of the test project in order to register the dependency injection services which will be used by all test cases in the assembly. A fast solution is to inherit from the web project's `Startup` class and replace some of the services with mocked ones by using the provided extension methods.
3656

3757
```c#
3858
namespace MyApp.Tests
@@ -78,8 +98,7 @@ namespace MyApp.Tests.Controllers
7898
}
7999
```
80100

81-
The example uses [xUnit](http://xunit.github.io/) but you can use whatever testing framework you want.
82-
Basically, MyTested.AspNetCore.Mvc throws an unhandled exception with a friendly error message if the assertion does not pass and the test fails.
101+
Basically, MyTested.AspNetCore.Mvc throws an unhandled exception with a friendly error message if the assertion does not pass and the test fails. The example uses [xUnit](http://xunit.github.io/) but you can use any other framework you like. See the [samples](https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/tree/master/samples) for other types of test runners and `Startup` class configurations.
83102

84103
## Examples
85104

@@ -88,7 +107,7 @@ Here are some random examples of what the fluent testing API is capable of:
88107
```c#
89108
// tests a route for correct controller, action and resolved route values
90109
MyMvc
91-
.Routes()
110+
.Routing()
92111
.ShouldMap(request => request
93112
.WithLocation("/My/Action/1")
94113
.WithMethod(HttpMethod.Post)
@@ -151,7 +170,9 @@ MyMvc
151170
.MemoryCache(cache => cache
152171
.ContainingEntry(entry => entry
153172
.WithKey("CacheEntry")
154-
.WithSlidingExpiration(TimeSpan.FromMinutes(10))))
173+
.WithSlidingExpiration(TimeSpan.FromMinutes(10))
174+
.WithValueOfType<CachedModel>()
175+
.Passing(a => a.Id == 1)))
155176
.AndAlso()
156177
.ShouldReturn()
157178
.View()
@@ -169,7 +190,8 @@ MyMvc
169190
.ChangingActionNameTo("AnotherAction"));
170191

171192
// tests whether model state error exists by using lambda expression
172-
// and specific tests for the error messages
193+
// and with specific tests for the error messages
194+
// and tests whether the action return view with the same request model
173195
MyMvc
174196
.Controller<MvcController>()
175197
.Calling(c => c.MyAction(requestWithErrors))
@@ -178,7 +200,10 @@ MyMvc
178200
.ContainingNoErrorFor(m => m.NonRequiredProperty)
179201
.AndAlso()
180202
.ContainingErrorFor(m => m.RequiredProperty)
181-
.ThatEquals("The RequiredProperty field is required."));
203+
.ThatEquals("The RequiredProperty field is required."))
204+
.AndAlso()
205+
.ShouldReturn()
206+
.View(requestWithErrors);
182207

183208
// tests whether the action throws
184209
// with exception of certain type and with certain message

docs/_docfx/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
###############
3+
# folder #
4+
###############
5+
/**/DROP/
6+
/**/TEMP/
7+
/**/packages/
8+
/**/bin/
9+
/**/obj/
10+
.
11+
../src
12+
../test

docs/_docfx/api/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
###############
3+
# temp file #
4+
###############
5+
*.yml

docs/_docfx/api/.manifest

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

docs/_docfx/api/index.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Welcome to the API Reference
2+
3+
Here you will find [My Tested ASP.NET Core MVC](https://mytestedasp.net/Core/Mvc) API reference containing detailed information on all publicly available assertion methods and classes.
4+
5+
<strong class="article-contents">Test case starting points</strong>
6+
7+
- [MyMvc](/api/MyTested.AspNetCore.Mvc.MyMvc.html) - contains all available starting points
8+
- [MyApplication](/api/MyTested.AspNetCore.Mvc.MyApplication.html) - specifies the test application
9+
- [MyController](/api/MyTested.AspNetCore.Mvc.MyController-1.html) - specifies controller test case
10+
- [MyViewComponent](/api/MyTested.AspNetCore.Mvc.MyViewComponent-1.html) - specifies view component test case
11+
- [MyRouting](/api/MyTested.AspNetCore.Mvc.MyRouting.html) - specifies route test case
12+
13+
<strong class="article-contents">Commonly used test builders</strong>
14+
15+
- [IControllerBuilder](/api/MyTested.AspNetCore.Mvc.Builders.Contracts.Controllers.IControllerBuilder-1.html) - controller test builder
16+
- [IViewComponentBuilder](/api/MyTested.AspNetCore.Mvc.Builders.Contracts.ViewComponents.IViewComponentBuilder-1.html) - view component test builder
17+
- [IRouteTestBuilder](/api/MyTested.AspNetCore.Mvc.Builders.Contracts.Routes.IRouteTestBuilder.html) - route test builder
18+
- [IApplicationConfigurationBuilder](/api/MyTested.AspNetCore.Mvc.Builders.Contracts.Application.IApplicationConfigurationBuilder.html) - application configuration builder
19+
20+
<strong class="article-contents">Helper classes</strong>
21+
22+
- [From](/api/MyTested.AspNetCore.Mvc.From.html) - helps with resolving values in lambda expressions
23+
- [With](/api/MyTested.AspNetCore.Mvc.With.html) - helps with null, default and ignored values
24+
- [AuthenticationScheme](/api/MyTested.AspNetCore.Mvc.AuthenticationScheme.html) - contains common authentication schemes
25+
- [ContentType](/api/MyTested.AspNetCore.Mvc.ContentType.html) - contains common content type header values
26+
- [HttpHeader](/api/MyTested.AspNetCore.Mvc.HttpHeader.html) - contains common HTTP header names
27+
- [HttpMethod](/api/MyTested.AspNetCore.Mvc.HttpMethod.html) - contains common HTTP methods
28+
- [HttpScheme](/api/MyTested.AspNetCore.Mvc.HttpScheme.html) - contains common HTTP schemes
29+
- [HttpStatusCode](/api/MyTested.AspNetCore.Mvc.HttpStatusCode.html) - contains common HTTP status codes

docs/_docfx/custom/favicon.ico

1.12 KB
Binary file not shown.

docs/_docfx/custom/index.html.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function transform(model, _attrs){
2+
var vm = {};
3+
// Copy default _attrs and override name/id
4+
for (var key in _attrs) {
5+
if (_attrs.hasOwnProperty(key)) {
6+
vm[key] = _attrs[key];
7+
}
8+
}
9+
// Copy model
10+
for (var key in model) {
11+
if (model.hasOwnProperty(key)) {
12+
vm[key] = model[key];
13+
}
14+
}
15+
// If toc is not defined in model, read it from _attrs
16+
if (vm._tocPath && vm._tocPath.indexOf("~/") == 0) {
17+
vm._tocPath = vm._tocPath.substring(2);
18+
}
19+
if (vm._navPath === vm._tocPath){
20+
vm._allowToc = false;
21+
}else{
22+
vm._allowToc = true;
23+
}
24+
if (!vm.hasOwnProperty("_allowAffix")) {
25+
vm._allowAffix = true;
26+
} else {
27+
// parse from string to bool
28+
vm._allowAffix = vm._allowAffix === "true"
29+
}
30+
return vm;
31+
}

docs/_docfx/custom/index.html.tmpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{!include(/^styles/.*/)}}
2+
{{!include(/^fonts/.*/)}}
3+
{{!include(favicon.ico)}}
4+
{{!include(logo.svg)}}
5+
<!DOCTYPE html>
6+
<!--[if IE]><![endif]-->
7+
<html>
8+
{{>partials/head}}
9+
<body data-spy="scroll" data-target="#affix">
10+
<div id="wrapper">
11+
<header>
12+
{{>partials/navbar}}
13+
</header>
14+
{{{conceptual}}}
15+
{{>partials/footer}}
16+
</div>
17+
{{>partials/scripts}}
18+
</body>
19+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<footer>
2+
<div class="grad-bottom"></div>
3+
<div class="footer">
4+
<div class="container">
5+
<span class="pull-right">
6+
<a href="#top">Back to top</a>
7+
</span>
8+
<span>Copyright © 2015-2016 <strong><a href="http://mytestedasp.net">MyTestedASP.NET</a></strong>. All Rights Reserved. Generated by <strong><a href="http://dotnet.github.io/docfx/">DocFX</a></strong></span>
9+
</div>
10+
</div>
11+
</footer>

0 commit comments

Comments
 (0)