public void MultitenantTests_Get_NonExisting_Null() { var container = new StashboxContainer(); var md = new TenantDistributor(container); Assert.Null(md.GetTenant("A")); }
public void MultitenantTests_Configure_Dep() { var container = new StashboxContainer(); container.Register <D>(); container.Register <IA, A>(); var md = new TenantDistributor(container); md.ConfigureTenant("A", c => c.Register <IA, B>()); var tenant = md.GetTenant("A"); Assert.IsType <A>(container.Resolve <D>().Ia); Assert.IsType <B>(md.GetTenant("A").Resolve <D>().Ia); }
public async Task MultitenantTests_Dispose_Async_Tenant() { var container = new StashboxContainer(c => c.WithDisposableTransientTracking()); var md = new TenantDistributor(container); md.ConfigureTenant("C", c => c.Register <IA, C>()); var tenant = md.GetTenant("C"); var inst = (C)tenant.Resolve <IA>(); await md.DisposeAsync(); Assert.True(inst.Disposed); Assert.Throws <ObjectDisposedException>(() => container.Resolve <IA>()); Assert.Throws <ObjectDisposedException>(() => tenant.Resolve <IA>()); }