public async void AddsAutofacDependencyScopeToHttpRequestMessage() { var request = new HttpRequestMessage(); var context = new OwinContext(); request.Properties.Add("MS_OwinContext", context); var container = new ContainerBuilder().Build(); context.Set(Constants.OwinLifetimeScopeKey, container); var fakeHandler = new FakeInnerHandler {Message = new HttpResponseMessage(HttpStatusCode.OK)}; var handler = new DependencyScopeHandler {InnerHandler = fakeHandler}; var invoker = new HttpMessageInvoker(handler); await invoker.SendAsync(request, new CancellationToken()); var scope = (AutofacWebApiDependencyScope)request.Properties[HttpPropertyKeys.DependencyScope]; Assert.That(scope.LifetimeScope, Is.EqualTo(container)); }
public async void AddsAutofacDependencyScopeToHttpRequestMessage() { var request = new HttpRequestMessage(); var context = new OwinContext(); request.Properties.Add("MS_OwinContext", context); var container = new ContainerBuilder().Build(); context.Set(Constants.OwinLifetimeScopeKey, container); var fakeHandler = new FakeInnerHandler { Message = new HttpResponseMessage(HttpStatusCode.OK) }; var handler = new DependencyScopeHandler { InnerHandler = fakeHandler }; var invoker = new HttpMessageInvoker(handler); await invoker.SendAsync(request, new CancellationToken()); var scope = (AutofacWebApiDependencyScope)request.Properties[HttpPropertyKeys.DependencyScope]; Assert.That(scope.LifetimeScope, Is.EqualTo(container)); }