Unit test ASP.NET Web Api attrubute routing

by sunil ravulapalli /13. November 2013 03:50 /asp.net-web-api /Comments (0)

Most of the stuff is standard expect you need to call config.EnsureInitialized() after WebApiConfig.Register(config)

            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost.com/api/v1/account/12345678/info");
            var config = new HttpConfiguration();

            var route = WebApi.RouteRequest(config, request);

            Assert.AreEqual("InfoController", route.Controller.Name);
            Assert.AreEqual("Get", route.Action);
blog comments powered by Disqus