/// <summary> /// Registers a route for a specific OWIN application entry point. /// </summary> /// <typeparam name="TApp">The OWIN application entry point type.</typeparam> /// <param name="routes">The route collection.</param> /// <param name="name">The given name of the route.</param> /// <param name="pathBase">The route path to map to the given OWIN application.</param> /// <param name="app">The OWIN application entry point.</param> /// <returns>The created route.</returns> public static RouteBase MapOwinPath <TApp>(this RouteCollection routes, string name, string pathBase, TApp app) { if (app == null) { throw new ArgumentNullException("app"); } OwinAppContext appDelegate = OwinBuilder.Build(builder => builder.Use(new Func <object, object>(_ => app))); return(Add(routes, name, new OwinRoute(pathBase, () => appDelegate))); }
public Task ItShouldCallAppDelegateWhenBeginProcessRequestCalled() { var httpHandler = new OwinHttpHandler(string.Empty, OwinBuilder.Build(WasCalledApp)); FakeHttpContext httpContext = NewHttpContext(new Uri("http://localhost")); Task task = Task.Factory.FromAsync(httpHandler.BeginProcessRequest, httpHandler.EndProcessRequest, httpContext, null); return(task.ContinueWith(_ => { task.Exception.ShouldBe(null); WasCalled.ShouldBe(true); })); }
public Task AppDelegateAccessorPassesFromOwinRouteThroughToOwinHttpHandler() { var route = new OwinRoute(string.Empty, () => OwinBuilder.Build(WasCalledApp)); FakeHttpContext httpContext = NewHttpContext(new Uri("http://localhost")); RequestContext requestContext = NewRequestContext(route, httpContext); Task task = ExecuteRequestContext(requestContext); return(task.ContinueWith(_ => { task.Exception.ShouldBe(null); WasCalled.ShouldBe(true); })); }
/// <summary> /// Registers a route for a specific OWIN application entry point. /// </summary> /// <typeparam name="TApp">The OWIN application entry point type.</typeparam> /// <param name="routes">The route collection.</param> /// <param name="name">The given name of the route.</param> /// <param name="pathBase">The route path to map to the given OWIN application.</param> /// <param name="app">The OWIN application entry point.</param> /// <returns>The created route.</returns> public static RouteBase MapOwinPath <TApp>(this RouteCollection routes, string name, string pathBase, TApp app) { OwinAppContext appDelegate = OwinBuilder.Build(builder => builder.Use(new Func <object, object>(_ => app))); return(Add(routes, name, new OwinRoute(pathBase, () => appDelegate))); }
/// <summary> /// Invokes the System.Action startup delegate to build the OWIN application /// and then registers a route for it on the given path. /// </summary> /// <param name="routes">The route collection.</param> /// <param name="pathBase">The route path to map to the given OWIN application.</param> /// <param name="startup">A System.Action delegate invoked to build the OWIN application.</param> /// <returns>The created route.</returns> public static RouteBase MapOwinPath(this RouteCollection routes, string pathBase, Action <IAppBuilder> startup) { OwinAppContext appDelegate = OwinBuilder.Build(startup); return(Add(routes, null, new OwinRoute(pathBase, () => appDelegate))); }