public async Task TransientServiceIsDefferentperTenant_WhenUseMultitenancy()
        {
            // Act
            string responseFirstTenant_11 = await ClientTransient.GetStringAsync(UrlTenant1).ConfigureAwait(false);

            string responseFirstTenant_12 = await ClientTransient.GetStringAsync(UrlTenant1).ConfigureAwait(false);

            string responseSecondTenant_21 = await ClientTransient.GetStringAsync(UrlTenant2).ConfigureAwait(false);

            string responseSecondTenant_22 = await ClientTransient.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));

            Assert.NotEqual(responseFirstTenant_11, responseFirstTenant_12);
            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();
        }
        public async Task CanRegisterAndOverrideSingletonServiceIsPerTenant_WhenUseMultitenancy2()
        {
            // Act
            string newAddedTenantUrl  = "/tenant-5-1";
            string newAddedTenantName = "Tenant 5";
            IOptionsMonitor <MultitenancyOptions <TestTenant> > options = Server
                                                                          .Host
                                                                          .Services
                                                                          .GetService(typeof(IOptionsMonitor <MultitenancyOptions <TestTenant> >)) as IOptionsMonitor <MultitenancyOptions <TestTenant> >;

            //BEFORE
            string responseNewTenant = await ClientTransient.GetStringAsync(newAddedTenantUrl).ConfigureAwait(false);

            // protected internal HttpClient ClientTransient { get; } = new TestServer(CreateWebHostBuilder<TestTransientStartup, TestTenant, TestTenantMemoryCacheResolver>()).CreateClient();

            Assert.True(string.IsNullOrWhiteSpace(responseNewTenant));
            Assert.True(options.CurrentValue.Tenants.Count == 4);

            //Add value in configuration
            SetConfig(new Dictionary <string, string>()
            {
                { "MultitenancyOptions:Tenants:4:Name", newAddedTenantName },
                { "MultitenancyOptions:Tenants:4:Theme", "" },
                { "MultitenancyOptions:Tenants:4:ConnectionString", "555555555555555" },
                { "MultitenancyOptions:Tenants:4:Hostnames:0", newAddedTenantUrl },
                { "MultitenancyOptions:Tenants:4:Hostnames:1", "localhost:555555555555555" },
            });

            //AFTER
            // wait 1 second
            Thread.Sleep(1000);

            SetConfig(new Dictionary <string, string>()
            {
                { "MultitenancyOptions:Tenants:4:Name", newAddedTenantName },
                { "MultitenancyOptions:Tenants:4:Theme", "" },
                { "MultitenancyOptions:Tenants:4:ConnectionString", "555555555555555" },
                { "MultitenancyOptions:Tenants:4:Hostnames:0", newAddedTenantUrl },
                { "MultitenancyOptions:Tenants:4:Hostnames:1", "localhost:555555555555555" },
            });

            // wait 1 second
            Thread.Sleep(1000);

            options = Server
                      .Host
                      .Services
                      .GetService(typeof(IOptionsMonitor <MultitenancyOptions <TestTenant> >)) as IOptionsMonitor <MultitenancyOptions <TestTenant> >;
            responseNewTenant = await ClientTransient.GetStringAsync(newAddedTenantUrl).ConfigureAwait(false);

            //Assert.StartsWith(newAddedTenantName, responseNewTenant);
            Assert.True(options.CurrentValue.Tenants.Count == 5);
        }