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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -