c# - Unit test asp.net route mapping extension method -
i have extension class routes. want test updated list of routecollection. extract:
public static void mapmyroutes(this routecollection routes) { //do stuff routes.maphttproute(null, controllerpath.path, new { @namespace = controllerpath.namespace, controller = controllerpath.controllername, id = urlparameter.optional }); }
i want unit test extension, can't work out how extract mapped url routecollection:
this test:
[testmethod] public void testmapmyroutesmapscorrectly() { var routes = new routecollection(); routes.mapmyroutes(); foreach (var route in routes) { assert.areequal(route.??, "v1/api/myroute"); } }
routescollection defined collection<routebase>
cast each item route, ie:
foreach (var route in routes.cast<route>()) { // url may not in fact correct property … assert.areequal(route.url, "v1/api/myroute"); }
Comments
Post a Comment