public async Task ScopedServiceIsDefferentperTenant_WhenUseMultitenancy() { // Act string responseFirstTenant_11 = await ClientScoped.GetStringAsync(UrlTenant1).ConfigureAwait(false); string responseFirstTenant_12 = await ClientScoped.GetStringAsync(UrlTenant1).ConfigureAwait(false); string responseSecondTenant_21 = await ClientScoped.GetStringAsync(UrlTenant2).ConfigureAwait(false); string responseSecondTenant_22 = await ClientScoped.GetStringAsync(UrlTenant2).ConfigureAwait(false); // Assert string[] col = new[] { responseFirstTenant_11, responseFirstTenant_12, responseSecondTenant_21, responseSecondTenant_22 }; Assert.All(col, x => Assert.NotNull(x)); Assert.All(col, x => Assert.NotEqual(string.Empty, x)); // Begin with tenant1. Assert.All(new[] { responseFirstTenant_11, responseFirstTenant_12 }, x => Assert.StartsWith("Tenant 1", x)); // Begin with tenant2. Assert.All(new[] { responseSecondTenant_21, responseSecondTenant_22 }, x => Assert.StartsWith("Tenant 2", x)); // singleton is same between same tenant,and different with different tenant Assert.NotEqual(responseFirstTenant_11, responseFirstTenant_12); Assert.NotEqual(responseSecondTenant_21, responseSecondTenant_22); Assert.NotEqual(responseFirstTenant_11, responseSecondTenant_21); }
/// <summary> /// Do the dispose. /// </summary> public void Dispose() { Server?.Dispose(); ClientTransient?.Dispose(); ClientSingleton?.Dispose(); ClientScoped?.Dispose(); ClientOverrideTransient?.Dispose(); ClientOverrideSingleton?.Dispose(); }