public void Load_ConfigServerReturnsBadStatus_FailFastEnabled()
        {
            // Arrange
            var startup = new TestConfigServerStartup("", 500);
            var server = TestServer.Create(startup.Configure);
            ConfigServerClientSettingsBase settings = new ConfigServerClientSettingsBase();
            settings.Uri = "http://localhost:8888";
            settings.Name = "myName";
            settings.FailFast = true;
            server.BaseAddress = new Uri(settings.Uri);
            ConfigServerConfigurationProviderBase provider = new ConfigServerConfigurationProviderBase(settings, server.CreateClient());

            // Act and Assert
            var ex = Assert.Throws<ConfigServerException>(() => provider.Load());

        }
        public void Load_ChangesDataDictionary()
        {
            // Arrange
            var environment = @"
{
    'name': 'testname',
    'profiles': ['Production'],
    'label': 'testlabel',
    'version': 'testversion',
    'propertySources': [ 
        { 
            'name': 'source',
            'source': {
                'key1': 'value1',
                'key2': 10
            }
        }
    ]
}";
            var startup = new TestConfigServerStartup(environment, 200);
            var server = TestServer.Create(startup.Configure);
            ConfigServerClientSettingsBase settings = new ConfigServerClientSettingsBase();
            settings.Uri = "http://localhost:8888";
            settings.Name = "myName";
            server.BaseAddress = new Uri(settings.Uri);
            ConfigServerConfigurationProviderBase provider = new ConfigServerConfigurationProviderBase(settings, server.CreateClient());

            // Act and Assert
            provider.Load();
            Assert.NotNull(startup.LastRequest);
            Assert.Equal("/" + settings.Name + "/" + settings.Environment, startup.LastRequest.Path.Value);

            string value;
            Assert.True(provider.TryGet("key1", out value));
            Assert.Equal("value1", value);
            Assert.True(provider.TryGet("key2", out value));
            Assert.Equal("10", value);
        }
        public void Load_ConfigServerReturnsNotFoundStatus()
        {
            // Arrange
            var startup = new TestConfigServerStartup("", 404);
            var server = TestServer.Create(startup.Configure);
            ConfigServerClientSettingsBase settings = new ConfigServerClientSettingsBase();
            settings.Uri = "http://localhost:8888";
            settings.Name = "myName";
            server.BaseAddress = new Uri(settings.Uri);
            ConfigServerConfigurationProviderBase provider = new ConfigServerConfigurationProviderBase(settings, server.CreateClient());

            // Act and Assert
            provider.Load();
            Assert.NotNull(startup.LastRequest);
            Assert.Equal("/" + settings.Name + "/" + settings.Environment, startup.LastRequest.Path.Value);
            Assert.Equal(9, provider.Properties.Count);
        }