public void InvokeMethodThrowsExceptionIfRequestNull()
        {
            var handler = new DependencyScopeHandler();
            var invoker = new HttpMessageInvoker(handler);

            var exception = Assert.Throws<ArgumentNullException>(() => invoker.SendAsync(null, new CancellationToken()));

            Assert.That(exception.ParamName, Is.EqualTo("request"));
        }
        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));
        }