You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-9Lines changed: 34 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,33 @@ MyTested.AspNetCore.Mvc is a unit testing library (currently in preview version)
7
7
8
8
## Getting started
9
9
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.
11
11
12
12
## Installation
13
13
14
14
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.
15
15
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`
17
37
18
38
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.
19
39
@@ -32,7 +52,7 @@ Make sure to check out the [tutorial](http://docs.mytestedasp.net/tutorial/intro
32
52
33
53
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.
34
54
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.
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.
83
102
84
103
## Examples
85
104
@@ -88,7 +107,7 @@ Here are some random examples of what the fluent testing API is capable of:
88
107
```c#
89
108
// tests a route for correct controller, action and resolved route values
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
+
<strongclass="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
+
<strongclass="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
0 commit comments