public async Task RuntimeReplacementsShutdownInitialDiscoveryClient() { // arrange a basic ConfigServerDiscoveryService w/o logging var replacementDiscoveryClient = new TestDiscoveryClient(); var appSettings = new Dictionary <string, string> { { "testdiscovery:enabled", "true" } }; var config = new ConfigurationBuilder().AddInMemoryCollection(appSettings).Build(); var service = new ConfigServerDiscoveryService(config, new ConfigServerClientSettings()); var originalClient = service._discoveryClient as TestDiscoveryClient; // replace the bootstrapped eureka client with a test client await service.ProvideRuntimeReplacementsAsync(replacementDiscoveryClient, null); Assert.True(originalClient.HasShutdown, "ShutdownAsync() called on original discovery client."); Assert.False(replacementDiscoveryClient.HasShutdown, "ShutdownAsync() NOT called on replacement discovery client."); }
public async Task RuntimeReplacementsCanBeProvided() { // arrange a basic ConfigServerDiscoveryService w/o logging var appSettings = new Dictionary <string, string> { { "eureka:client:anything", "true" } }; var config = new ConfigurationBuilder().AddInMemoryCollection(appSettings).Build(); var testDiscoveryClient = new TestDiscoveryClient(); var logFactory = new LoggerFactory(); var service = new ConfigServerDiscoveryService(config, new ConfigServerClientSettings()); Assert.Null(service._logFactory); Assert.IsType <NullLogger>(service._logger); Assert.IsType <EurekaDiscoveryClient>(service._discoveryClient); // replace the bootstrapped eureka client with a test client await service.ProvideRuntimeReplacementsAsync(testDiscoveryClient, logFactory); Assert.NotNull(service._logFactory); Assert.IsAssignableFrom <ILogger <ConfigServerDiscoveryService> >(service._logger); }