public void GetServiceReturnsNullForUnregisteredService()
        {
            var lifetimeScope = new ContainerBuilder().Build().BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag);
            var dependencyScope = new AutofacWebApiDependencyScope(lifetimeScope);

            var service = dependencyScope.GetService(typeof(object));

            Assert.That(service, Is.Null);
        }
        public void GetServiceReturnsRegisteredService()
        {
            var builder = new ContainerBuilder();
            builder.Register(c => new object()).InstancePerRequest();
            var lifetimeScope = builder.Build().BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag);
            var dependencyScope = new AutofacWebApiDependencyScope(lifetimeScope);

            var service = dependencyScope.GetService(typeof(object));

            Assert.That(service, Is.Not.Null);
        }
        public void HandlerUpdatesDependencyScopeWithHttpRequestMessage()
        {
            var request = new HttpRequestMessage();
            var lifetimeScope = new ContainerBuilder().Build().BeginLifetimeScope(AutofacWebApiDependencyResolver.ApiRequestTag);
            var scope = new AutofacWebApiDependencyScope(lifetimeScope);
            request.Properties.Add(HttpPropertyKeys.DependencyScope, scope);

            CurrentRequestHandler.UpdateScopeWithHttpRequestMessage(request);

            Assert.That(scope.GetService(typeof(HttpRequestMessage)), Is.EqualTo(request));
        }