public void DoLoad_MultipleLabels_ChecksAllLabels() { // Arrange var environment = @" { 'name': 'testname', 'profiles': ['Production'], 'label': 'testlabel', 'version': 'testversion', 'propertySources': [ { 'name': 'source', 'source': { 'key1': 'value1', 'key2': 10 } } ] }"; IHostingEnvironment envir = new HostingEnvironment(); TestConfigServerStartup.Reset(); TestConfigServerStartup.Response = environment; TestConfigServerStartup.ReturnStatus = new int[] { 404, 200 }; TestConfigServerStartup.Label = "testlabel"; var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName); var server = new TestServer(builder); ConfigServerClientSettings settings = new ConfigServerClientSettings { Uri = "http://localhost:8888", Name = "myName", Label = "label,testlabel" }; server.BaseAddress = new Uri(settings.Uri); ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(settings, server.CreateClient()); // Act and Assert provider.DoLoad(); Assert.NotNull(TestConfigServerStartup.LastRequest); Assert.Equal(2, TestConfigServerStartup.RequestCount); Assert.Equal("/" + settings.Name + "/" + settings.Environment + "/testlabel", TestConfigServerStartup.LastRequest.Path.Value); }
public void DoLoad_MultipleLabels_ChecksAllLabels() { // Arrange var environment = @" { ""name"": ""testname"", ""profiles"": [""Production""], ""label"": ""testlabel"", ""version"": ""testversion"", ""propertySources"": [ { ""name"": ""source"", ""source"": { ""key1"": ""value1"", ""key2"": 10 } } ] }"; var envir = HostingHelpers.GetHostingEnvironment(); TestConfigServerStartup.Reset(); TestConfigServerStartup.Response = environment; TestConfigServerStartup.ReturnStatus = new int[] { 404, 200 }; TestConfigServerStartup.Label = "testlabel"; var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName); var server = new TestServer(builder); var settings = new ConfigServerClientSettings { Uri = "http://localhost:8888", Name = "myName", Label = "label,testlabel" }; server.BaseAddress = new Uri(settings.Uri); var provider = new ConfigServerConfigurationProvider(settings, server.CreateClient()); // Act and Assert provider.DoLoad(); Assert.NotNull(TestConfigServerStartup.LastRequest); Assert.Equal(2, TestConfigServerStartup.RequestCount); Assert.Equal("/" + settings.Name + "/" + settings.Environment + "/testlabel", TestConfigServerStartup.LastRequest.Path.Value); }