public void GetTenantScope_SubsequentRetrievalsGetTheSameLifetimeScope()
 {
     var strategy = new StubTenantIdentificationStrategy()
     {
         TenantId = "tenant1"
     };
     var mtc = new MultitenantContainer(strategy, new ContainerBuilder().Build());
     mtc.ConfigureTenant("tenant1", b => b.RegisterType<StubDependency1Impl2>().As<IStubDependency1>());
     var scope1 = mtc.GetTenantScope("tenant1");
     var scope2 = mtc.GetTenantScope("tenant1");
     Assert.AreSame(scope1, scope2, "The tenant scope should not change across subsequent retrievals.");
 }
 public void GetTenantScope_GetsTenantScopeForConfiguredTenant()
 {
     var strategy = new StubTenantIdentificationStrategy()
     {
         TenantId = "tenant1"
     };
     var mtc = new MultitenantContainer(strategy, new ContainerBuilder().Build());
     mtc.ConfigureTenant("tenant1", b => b.RegisterType<StubDependency1Impl2>().As<IStubDependency1>());
     var scope = mtc.GetTenantScope("tenant1");
     Assert.IsNotNull(scope, "The tenant scope retrieved not be null.");
     Assert.AreNotSame(mtc.ApplicationContainer, scope, "The tenant scope should be a real scope, not just the application container.");
 }
 public void GetTenantScope_NullIsDefaultTenant()
 {
     var strategy = new StubTenantIdentificationStrategy()
     {
         TenantId = "tenant1"
     };
     var mtc = new MultitenantContainer(strategy, new ContainerBuilder().Build());
     var scope = mtc.GetTenantScope(null);
     Assert.IsNotNull(scope, "The default tenant scope should not be null.");
     Assert.AreNotSame(mtc.ApplicationContainer, scope, "The default tenant scope should be a real scope, not just the application container.");
 }
 public void GetCurrentTenantScope_TenantNotFound()
 {
     var strategy = new StubTenantIdentificationStrategy()
     {
         TenantId = "tenant1",
         IdentificationSuccess = false
     };
     var mtc = new MultitenantContainer(strategy, new ContainerBuilder().Build());
     var current = mtc.GetCurrentTenantScope();
     var tenant = mtc.GetTenantScope(null);
     Assert.AreSame(tenant, current, "The current scope should be the default tenant scope for the unidentified tenant.");
 }