public DefaultRequestDispatcherFixture() { this.responseProcessors = new List<IResponseProcessor>(); this.routeResolver = A.Fake<IRouteResolver>(); this.routeInvoker = A.Fake<IRouteInvoker>(); this.negotiator = A.Fake<IResponseNegotiator>(); A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<CancellationToken>._, A<DynamicDictionary>._, A<NancyContext>._)) .ReturnsLazily(async arg => { var routeResult = ((Route)arg.Arguments[0]).Invoke((DynamicDictionary)arg.Arguments[2], new CancellationToken()).ConfigureAwait(false); var x = await routeResult; return (Response)x; }); this.requestDispatcher = new DefaultRequestDispatcher(this.routeResolver, this.responseProcessors, this.routeInvoker, this.negotiator); var resolvedRoute = new ResolveResult { Route = new FakeRoute(), Parameters = DynamicDictionary.Empty, Before = null, After = null, OnError = null }; A.CallTo(() => this.routeResolver.Resolve(A<NancyContext>._)).Returns(resolvedRoute); }
public DefaultRequestDispatcherFixture() { this.responseProcessors = new List<IResponseProcessor>(); this.routeResolver = A.Fake<IRouteResolver>(); this.routeInvoker = A.Fake<IRouteInvoker>(); A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<DynamicDictionary>._, A<NancyContext>._)).ReturnsLazily(arg => { return (Response)((Route)arg.Arguments[0]).Action.Invoke(arg.Arguments[1]); }); this.requestDispatcher = new DefaultRequestDispatcher(this.routeResolver, this.responseProcessors, this.routeInvoker); var resolvedRoute = new ResolveResult { Route = new FakeRoute(), Parameters = DynamicDictionary.Empty, Before = null, After = null, OnError = null }; A.CallTo(() => this.routeResolver.Resolve(A<NancyContext>._)).Returns(resolvedRoute); }
public DefaultRequestDispatcherFixture() { this.responseProcessors = new List<IResponseProcessor>(); this.routeResolver = A.Fake<IRouteResolver>(); this.routeInvoker = A.Fake<IRouteInvoker>(); A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<CancellationToken>._, A<DynamicDictionary>._, A<NancyContext>._)).ReturnsLazily(arg => { var tcs = new TaskCompletionSource<Response>(); var actionResult = ((Route)arg.Arguments[0]).Action.Invoke(arg.Arguments[2], new CancellationToken()); var result = actionResult.Result; tcs.SetResult(result); return tcs.Task; }); this.requestDispatcher = new DefaultRequestDispatcher(this.routeResolver, this.responseProcessors, this.routeInvoker); var resolvedRoute = new ResolveResult { Route = new FakeRoute(), Parameters = DynamicDictionary.Empty, Before = null, After = null, OnError = null }; A.CallTo(() => this.routeResolver.Resolve(A<NancyContext>._)).Returns(resolvedRoute); }