public void ShouldCreateServiceProvider()
        {
            var serviceCollection = new ServiceCollection();
            var factory           = new LightInjectServiceProviderFactory();
            var container         = factory.CreateBuilder(serviceCollection);
            var provider          = factory.CreateServiceProvider(container);

            Assert.IsAssignableFrom <IServiceContainer>(container);
        }
        public void ShouldDisposeRootScopeWhenProviderIsDisposed()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <DisposableFoo>();
            var factory   = new LightInjectServiceProviderFactory();
            var container = factory.CreateBuilder(serviceCollection);
            var provider  = factory.CreateServiceProvider(container);

            var foo = provider.GetService <DisposableFoo>();

            ((IDisposable)provider).Dispose();

            Assert.True(foo.IsDisposed);
        }
        public void ShouldDisposeRootScopeWhenProviderRequestedFromContainerIsDisposed()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <DisposableFoo>();

            var factory           = new LightInjectServiceProviderFactory(new ServiceContainer(ContainerOptions.Default.WithMicrosoftSettings()));
            var container         = factory.CreateBuilder(serviceCollection);
            var provider          = factory.CreateServiceProvider(container);
            var requestedProvider = provider.GetService <IServiceProvider>();

            var foo = provider.GetService <DisposableFoo>();

            ((IDisposable)requestedProvider).Dispose();

            Assert.True(foo.IsDisposed);
        }