Skip to content

Commit db0ca36

Browse files
committed
Updated README.md
1 parent cd804c5 commit db0ca36

File tree

2 files changed

+28
-91
lines changed

2 files changed

+28
-91
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ Zlib/libpng License -
6666
Commercial License
6767
===========================================================================
6868
In addition to this license, MyTested.Mvc is offered under free or paid commercial licenses.
69-
see https://mytestedasp.net/products/mvc#pricing for details.
69+
see [https://mytestedasp.net/products/mvc#pricing](https://mytestedasp.net/products/mvc#pricing) for details.

README.md

Lines changed: 27 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -3,153 +3,90 @@ MyTested.Mvc - Fluent testing<br />&nbsp; for ASP.NET Core MVC</h1>
33

44
MyTested.Mvc is a unit testing library providing easy fluent interface to test the [ASP.NET Core MVC](https://github.com/aspnet/Mvc) framework. It is testing framework agnostic, so you can combine it with a test runner of your choice (e.g. xUnit, NUnit, etc.).
55

6-
## Tutorial and documentation
6+
## Getting started
77

8-
Please see the [documentation](https://github.com/ivaylokenov/MyTested.WebApi/tree/master/documentation) for full list of available features. Everything listed in the documentation is 100% covered by [more than 800 unit tests](https://github.com/ivaylokenov/MyTested.WebApi/tree/master/src/MyTested.WebApi.Tests) and should work correctly. Almost all items in the [issues page](https://github.com/ivaylokenov/MyTested.WebApi/issues) are expected future features and enhancements.
8+
It is strongly advised to start with the [tutorial](http://ivaylokenov.github.io/MyTested.Mvc/tutorial/intro.html) in order to get familiar with MyTested.Mvc. Additionally, you may see the [documentation](http://ivaylokenov.github.io/MyTested.Mvc/guide/intro.html) for full list of available features. MyTested.Mvc is 100% covered by [more than 1500 unit tests](https://github.com/ivaylokenov/MyTested.Mvc/tree/master/test/) and should work correctly. Almost all items in the [issues page](https://github.com/ivaylokenov/MyTested.Mvc/issues) are expected future features and enhancements.
99

1010
## Installation
1111

12-
You can install this library using NuGet into your Test class project. It will automatically reference the needed dependencies of Microsoft.AspNet.WebApi.Core (≥ 5.1.0) and Microsoft.Owin.Testing (≥ 3.0.1) for you. .NET 4.5+ is needed. Make sure your solution has the same versions of the mentioned dependencies in all projects where you are using them. For example, if you are using Microsoft.AspNet.WebApi.Core 5.2.3 in your Web project, the same version should be used after installing MyTested.WebApi in your Tests project.
12+
You can install this library using NuGet into your test project (or reference it directly in your `project.json` file). Currently MyTested.Mvc works with ASP.NET Core MVC RC2.
1313

14-
Install-Package MyTested.WebApi
14+
Install-Package MyTested.Mvc
1515

16-
After the downloading is complete, just add `using MyTested.WebApi;` and you are ready to test in the most elegant and developer friendly way.
16+
After the downloading is complete, just add `using MyTested.Mvc;` to your source code and you are ready to test in the most elegant and developer friendly way.
1717

18-
using MyTested.WebApi;
18+
using MyTested.Mvc;
1919

2020
For other interesting packages check out:
2121

22+
- [MyTested.WebApi](https://github.com/ivaylokenov/MyTested.WebApi) - fluent testing framework for ASP.NET Web API 2
23+
- [MyTested.HttpServer](https://github.com/ivaylokenov/MyTested.HttpServer) - fluent testing framework for remote HTTP servers
2224
- [AspNet.Mvc.TypedRouting](https://github.com/ivaylokenov/AspNet.Mvc.TypedRouting) - typed routing and link generation for ASP.NET Core MVC
2325
- [ASP.NET MVC 5 Lambda Expression Helpers](https://github.com/ivaylokenov/ASP.NET-MVC-Lambda-Expression-Helpers) - typed expression based link generation for ASP.NET MVC 5
2426

2527
## How to use
2628

27-
Make sure to check out [the documentation](https://github.com/ivaylokenov/MyTested.WebApi/tree/master/documentation) for full list of available features.
28-
You can also check out [the provided samples](https://github.com/ivaylokenov/MyTested.WebApi/tree/master/samples) for real-life ASP.NET Web API application testing.
29+
Make sure to check out the [tutorial](http://ivaylokenov.github.io/MyTested.Mvc/tutorial/intro.html) and the [documentation](http://ivaylokenov.github.io/MyTested.Mvc/guide/intro.html) for a preview of the available features.
30+
You can also check out the [provided samples](https://github.com/ivaylokenov/MyTested.Mvc/tree/master/samples) for real-life ASP.NET Core MVC application testing.
2931

30-
Basically you can create a test case by using the fluent API the library provides. You are given a static `MyWebApi` class from which all assertions can be easily configured.
32+
Basically you can create a test case by using the fluent API the library provides. You are given a static `MyMvc` class from which all assertions can be easily configured.
3133

3234
```c#
3335
namespace MyApp.Tests.Controllers
3436
{
35-
using MyTested.WebApi;
37+
using MyTested.Mvc;
3638

3739
using MyApp.Controllers;
38-
using NUnit.Framework;
40+
using Xunit;
3941

40-
[TestFixture]
4142
public class HomeControllerShould
4243
{
43-
[Test]
44-
public void ReturnOkWhenCallingGetAction()
44+
[Fact]
45+
public void ReturnViewWhenCallingIndexAction()
4546
{
46-
MyWebApi
47+
MyMvc
4748
.Controller<HomeController>()
48-
.Calling(c => c.Get())
49+
.Calling(c => c.Index())
4950
.ShouldReturn()
50-
.Ok();
51+
.View();
5152
}
5253
}
5354
}
5455
```
5556

56-
The example uses NUnit but you can use whatever testing framework you want.
57-
Basically, MyTested.WebApi throws an unhandled exception if the assertion does not pass and the test fails.
57+
The example uses [xUnit](http://xunit.github.io/) but you can use whatever testing framework you want.
58+
Basically, MyTested.Mvc throws an unhandled exception with a friendly error message if the assertion does not pass and the test fails.
5859

5960
Here are some random examples of what the fluent testing API is capable of:
6061

6162
```c#
6263
// tests a route for correct controller, action and resolved route values
63-
MyWebApi
64-
.Routes()
65-
.ShouldMap("api/WebApiController/SomeAction/5")
66-
.WithJsonContent(@"{""SomeInt"": 1, ""SomeString"": ""Test""}")
67-
.And()
68-
.WithHttpMethod(HttpMethod.Post)
69-
.To<WebApiController>(c => c.SomeAction(5, new RequestModel
70-
{
71-
SomeInt = 1,
72-
SomeString = "Test"
73-
}))
74-
.AndAlso()
75-
.ToNoHandler()
76-
.AndAlso()
77-
.ToValidModelState();
64+
7865

7966
// injects dependencies into controller
8067
// and mocks authenticated user
8168
// and tests for valid model state
8269
// and tests response model from Ok result with specific assertions
83-
MyWebApi
84-
.Controller<WebApiController>()
85-
.WithResolvedDependencyFor<IInjectedService>(mockedInjectedService)
86-
.WithResolvedDependencyFor<IAnotherInjectedService>(anotherMockedInjectedService);
87-
.WithAuthenticatedUser(user => user.WithUsername("NewUserName"))
88-
.Calling(c => c.SomeAction(requestModel))
89-
.ShouldHave()
90-
.ValidModelState()
91-
.AndAlso()
92-
.ShouldReturn()
93-
.Ok()
94-
.WithResponseModelOfType<ResponseModel>()
95-
.Passing(m =>
96-
{
97-
Assert.AreEqual(1, m.Id);
98-
Assert.AreEqual("Some property value", m.SomeProperty);
99-
});
10070
10171
// tests whether model state error exists by using lambda expression
10272
// and specific tests for the error messages
103-
MyWebApi
104-
.Controller<WebApiController>()
105-
.Calling(c => c.SomeAction(requestModel))
106-
.ShouldHave()
107-
.ModelStateFor<RequestModel>()
108-
.ContainingModelStateErrorFor(m => m.SomeProperty).ThatEquals("Error message")
109-
.AndAlso()
110-
.ContainingModelStateErrorFor(m => m.SecondProperty).BeginningWith("Error")
111-
.AndAlso()
112-
.ContainingModelStateErrorFor(m => m.ThirdProperty).EndingWith("message")
113-
.AndAlso()
114-
.ContainingModelStateErrorFor(m => m.SecondProperty).Containing("ror mes");
11573
11674
// tests whether the action throws internal server error
11775
// with exception of certain type and with certain message
118-
MyWebApi
119-
.Controller<WebApiController>()
120-
.Calling(c => c.SomeAction())
121-
.ShouldReturn()
122-
.InternalServerError()
123-
.WithException()
124-
.OfType<SomeException>()
125-
.AndAlso()
126-
.WithMessage("Some exception message");
12776
12877
// run full pipeline integration test
129-
MyWebApi
130-
.Server()
131-
.Working(httpConfiguration)
132-
.WithHttpRequestMessage(
133-
request => request
134-
.WithMethod(HttpMethod.Post)
135-
.WithRequestUri("api/WebApiController/SomeAction/1"))
136-
.ShouldReturnHttpResponseMessage()
137-
.WithStatusCode(HttpStatusCode.OK)
138-
.AndAlso()
139-
.ContainingHeader("MyCustomHeader");
78+
79+
// ADD MORE SAMPLES
14080
```
14181

14282
## License
14383

144-
Code by Ivaylo Kenov. Copyright 2015 Ivaylo Kenov.
84+
Code by Ivaylo Kenov. Copyright 2015 Ivaylo Kenov ([http://mytestedasp.net](http://mytestedasp.net))
14585

146-
This library is intended to be used in both open-source and commercial environments. To allow its use in as many
147-
situations as possible, MyTested.WebApi is dual-licensed. You may choose to use MyTested.WebApi under either the Apache License,
148-
Version 2.0, or the Microsoft Public License (Ms-PL). These licenses are essentially identical, but you are
149-
encouraged to evaluate both to determine which best fits your intended use.
86+
MyTested.Mvc source code is available under GNU Affero General Public License/FOSS License Exception. Additionally, full-featured licenses can be requested for free by individuals, startups and educational institutions. Commercial licensing with private support is also available.
15087

151-
Refer to the [LICENSE](https://github.com/ivaylokenov/MyTested.WebApi/blob/master/LICENSE) for detailed information.
88+
See [https://mytestedasp.net/products/mvc#pricing](https://mytestedasp.net/products/mvc#pricing) and the [LICENSE](https://github.com/ivaylokenov/MyTested.Mvc/blob/master/LICENSE) for detailed information.
15289

15390
## Any questions, comments or additions?
15491

155-
If you have a feature request or bug report, leave an issue on the [issues page](https://github.com/ivaylokenov/MyTested.WebApi/issues) or send a [pull request](https://github.com/ivaylokenov/MyTested.WebApi/pulls). For general questions and comments, use the [StackOverflow](http://stackoverflow.com/) forum.
92+
If you have a feature request or bug report, leave an issue on the [issues page](https://github.com/ivaylokenov/MyTested.Mvc/issues) or send a [pull request](https://github.com/ivaylokenov/MyTested.Mvc/pulls). For general questions and comments, use the [StackOverflow](http://stackoverflow.com/) forum.

0 commit comments

Comments
 (0)