Info
Version: | 4.1.4.3 |
Author(s): | Chris F Carroll |
Last Update: | Tuesday, November 20, 2018 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | http://github.com/chrisfcarroll/TestBase |
NuGet Url: | https://www.nuget.org/packages/TestBase-Mvc |
Install
Install-Package TestBase-Mvc
dotnet add package TestBase-Mvc
paket add TestBase-Mvc
TestBase-Mvc Download (Unzip the "nupkg" after downloading)
Dependencies
- Microsoft.AspNet.Mvc(>= 4.0.20710)
- Microsoft.AspNet.Razor(>= 2.0.30506)
- Microsoft.AspNet.WebApi.Client(>= 4.0.30506)
- Microsoft.AspNet.WebApi.Core(>= 4.0.20710)
- Microsoft.AspNet.WebPages(>= 2.0.30506)
- Moq(>= 4.0.10827)
- Newtonsoft.Json(>= 7.0.1)
- TestBase(>= 4.1.4.1)
Tags
TestBase-Mvc adds a rich extensible set of fluent assertions for verifying Mvc ActionResults and for easy setup of ControllerContext and HttpContext for both Mvc and WebApi
TestBase.Shoulds
-------------------
Chainable fluent assertions get you to the point concisely
ControllerUnderTest.Action()
.ShouldbeViewResult()
.ShouldHaveModel<TModel>()
.ShouldEqualByValue(expected)
ControllerUnderTest.Action()
.ShouldBeRedirectToRouteResult()
.ShouldHaveRouteValue("expectedKey", [Optional] "expectedValue");
ShouldHaveViewDataContaining(), ShouldBeJsonResult() etc.
TestBase
----------
Controller extensions to fake the http request & context.
By injecting the RegisterRoutes method of your
MvcApplication, you can use and test Controller.Url with your application's configured routes.
ControllerUnderTest
.WithHttpContextAndRoutes(
[Optional] Action<RouteCollection> mvcApplicationRoutesRegistration,
[optional] string requestUrl,
[Optional] string query = "",
[Optional] string appVirtualPath = "/",
[Optional] HttpApplication applicationInstance)
ApiControllerUnderTest.WithWebApiHttpContext<T>(
HttpMethod httpMethod,
[Optional] string requestUri,
[Optional] string routeTemplate).