Exemplo n.º 1
0
        private IServiceProvider CreateServiceProvider(Func <TestServiceCollection, TestServiceCollection> func)
        {
            var collection = new TestServiceCollection();
            var factory    = new StKServiceProviderFactory();

            return(factory.CreateServiceProvider(factory.CreateBuilder(func(collection))));
        }
Exemplo n.º 2
0
        public void SafelyDisposeNestedProviderReferences()
        {
            // Arrange
            var collection = new TestServiceCollection();

            collection.AddTransient <ClassWithNestedReferencesToProvider>();
            var provider = CreateServiceProvider(collection);

            // Act
            var nester = provider.GetService <ClassWithNestedReferencesToProvider>();

            // Assert
            Assert.NotNull(nester);
            nester.Dispose();
            Assert.Null(nester);
        }