Created
February 28, 2009 13:29
-
-
Save hotgazpacho/71955 to your computer and use it in GitHub Desktop.
This file contains 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
[Test] | |
public void DefaultRouteMapsToHomeController() | |
{ | |
RouteData routeData = "~/".Route(); | |
Assert.That(routeData.Values["controller"], Is.EqualTo("home").IgnoreCase); | |
Assert.That(routeData.Values["action"], Is.EqualTo("index").IgnoreCase); | |
Assert.That(routeData.Values["id"], Is.Null); | |
} | |
[Test] | |
public void RouteWithOnlyControllerMapsToIndexAction() | |
{ | |
RouteData routeData = "~/Home".Route(); | |
Assert.That(routeData.Values["controller"], Is.EqualTo("home").IgnoreCase); | |
Assert.That(routeData.Values["action"], Is.EqualTo("index").IgnoreCase); | |
Assert.That(routeData.Values["id"], Is.Null); | |
} | |
[Test] | |
public void RouteWithOnlyControllerAndActionMapsToExpectedAction() | |
{ | |
string controller = "Home"; | |
string action = "About"; | |
RouteData routeData = string.Format("~/{0}/{1}", controller, action).Route(); | |
Assert.That(routeData.Values["controller"], Is.EqualTo(controller).IgnoreCase); | |
Assert.That(routeData.Values["action"], Is.EqualTo(action).IgnoreCase); | |
Assert.That(routeData.Values["id"], Is.Null); | |
} | |
[Test] | |
public void RouteWithControllerActionAndIdMapsWithId() | |
{ | |
string controller = "Home"; | |
string action = "Details"; | |
int id = 1; | |
RouteData routeData = string.Format("~/{0}/{1}/{2}", controller, action, id).Route(); | |
Assert.That(routeData.Values["controller"], Is.EqualTo(controller).IgnoreCase); | |
Assert.That(routeData.Values["action"], Is.EqualTo(action).IgnoreCase); | |
Assert.That(routeData.Values["id"], Is.EqualTo(id)); | |
} | |
[Test] | |
public void RouteWithTooManySegments() | |
{ | |
RouteData routeData = "~/Home/Details/1/c".Route(); | |
Assert.IsNull(routeData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment