private IServiceProvider CreateServiceProvider(Func <TestServiceCollection, TestServiceCollection> func) { var collection = new TestServiceCollection(); var factory = new StKServiceProviderFactory(); return(factory.CreateServiceProvider(factory.CreateBuilder(func(collection)))); }
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); }