mardi 26 juillet 2016

Way to ensure application contains correct action methods

I'm trying to write a unit test to ensure that the routing for my web app contains valid action method names. Is there a way for me to "mock call" the routes to make sure they work in a unit test? Or maybe a way to get a list of all the action methods in my application then compare it with what's in the routing config?

For example, if my route is:

routes.MapRoute(
            name: "RelativeURL",
            url: "{*relativeURL}",
            defaults: new { controller = "Home", action = "Foo" }
            );

And my home controller doesn't contain the action Foo.

I want to be able to catch this via a unit test. Any ideas?

Aucun commentaire:

Enregistrer un commentaire