Skip to content

Instantly share code, notes, and snippets.

@bitsprint
Created June 11, 2013 14:57
Show Gist options
  • Select an option

  • Save bitsprint/5757551 to your computer and use it in GitHub Desktop.

Select an option

Save bitsprint/5757551 to your computer and use it in GitHub Desktop.
Area Route Test
[Test]
public void TestRoute_RoutesToCorrectRoute()
{
var routes = new RouteCollection();
var areaRegistration = new FooAreaRegistration();
Assert.AreEqual("Foo", areaRegistration.AreaName);
var areaRegistrationContext = new AreaRegistrationContext(areaRegistration.AreaName, routes);
areaRegistration.RegisterArea(areaRegistrationContext);
var context = new Mock<HttpContextBase>();
context.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/Foo/Bar/Baz/123");
var routeData = routes.GetRouteData(context.Object);
Assert.IsNotNull(routeData, "Should have found the route");
Assert.AreEqual("Foo", routeData.DataTokens["area"]);
Assert.AreEqual("Bar", routeData.Values["controller"]);
Assert.AreEqual("Baz", routeData.Values["action"]);
Assert.AreEqual("123", routeData.Values["id"]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment