Last active
December 10, 2015 17:58
-
-
Save carolynvs/4471039 to your computer and use it in GitHub Desktop.
How to test a ASP.NET Web API route using my contribution to WebApiContrib, RouteTestingExtensions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Routing; | |
using WebApiContrib.Testing; | |
namespace FooBar | |
{ | |
[TestFixture] | |
public void RouteFixture | |
{ | |
[SetUp] | |
public void Setup() | |
{ | |
// Register your routes | |
RouteTable.Routes.Clear(); | |
RouteConfig.RegisterRoutes(RouteTable.Routes); | |
} | |
[Test] | |
public void ValidateRoute() | |
{ | |
// Assert that the url is routed using the appropriate controller and parameters | |
const string url = "~/api/sample/5"; | |
url.ShouldMapTo<SampleController>(x => x.Get(5)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment