public void UseWebApiWithServer_IfServerIsNull_Throws() { // Arrange IAppBuilder builder = CreateDummyAppBuilder(); HttpServer httpServer = null; // Act & Assert Assert.ThrowsArgumentNull(() => WebApiAppBuilderExtensions.UseWebApi(builder, httpServer), "httpServer"); }
public void UseWebApiWithConfiguration_IfConfigurationIsNull_Throws() { // Arrange IAppBuilder builder = CreateDummyAppBuilder(); HttpConfiguration configuration = null; // Act & Assert Assert.ThrowsArgumentNull(() => WebApiAppBuilderExtensions.UseWebApi(builder, configuration), "configuration"); }
public void UseWebApiWithConfiguration_IfBuilderIsNull_Throws() { // Arrange IAppBuilder builder = null; using (HttpConfiguration configuration = CreateConfiguration()) { // Act & Assert Assert.ThrowsArgumentNull(() => WebApiAppBuilderExtensions.UseWebApi(builder, configuration), "builder"); } }
public static void UseWebApi(this IAppBuilder app, HttpConfiguration config) { WebApiAppBuilderExtensions.UseWebApi(app, config); EnableCors(config); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { controller = "Push", id = RouteParameter.Optional } ); }