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 AddConfigServerClientSettings_ChangesDataDictionary()
        {
            // Arrange
            ConfigServerClientSettingsBase settings = new ConfigServerClientSettingsBase();

            settings.Enabled = true;
            settings.Environment = "environment";
            settings.FailFast = false;
            settings.Label = "label";
            settings.Name = "name";
            settings.Password = "******";
            settings.Uri = "http://foo.bar/";
            settings.Username = "******";
            settings.ValidateCertificates = false;
            ConfigServerConfigurationProviderBase provider = new ConfigServerConfigurationProviderBase(settings);


            // Act and Assert
            provider.AddConfigServerClientSettings();

            string value;

            Assert.True(provider.TryGet("spring:cloud:config:env", out value));
            Assert.Equal("environment", value);
            Assert.True(provider.TryGet("spring:cloud:config:label", out value));
            Assert.Equal("label", value);
            Assert.True(provider.TryGet("spring:cloud:config:name", out value));
            Assert.Equal("name", value);
            Assert.True(provider.TryGet("spring:cloud:config:password", out value));
            Assert.Equal("password", value);
            Assert.True(provider.TryGet("spring:cloud:config:uri", out value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:username", out value));
            Assert.Equal("username", value);

            Assert.True(provider.TryGet("spring:cloud:config:enabled", out value));
            Assert.Equal("True", value);
            Assert.True(provider.TryGet("spring:cloud:config:failFast", out value));
            Assert.Equal("False", value);
            Assert.True(provider.TryGet("spring:cloud:config:validate_certificates", out value));
            Assert.Equal("False", value);

        }
        public void AddPropertySource_ChangesDataDictionary()
        {
            // Arrange
            IDictionary<string,object> properties = new Dictionary<string, object>();
            properties["a.b.c.d"] = "value1";
            properties["a"] = "value2";
            properties["b"] = 10;
            PropertySource source = new PropertySource("test", properties );
            source.Name = "test";
            ConfigServerConfigurationProviderBase provider = new ConfigServerConfigurationProviderBase(new ConfigServerClientSettingsBase());

            // Act and Assert
            provider.AddPropertySource(source);

            string value;
            Assert.True(provider.TryGet("a:b:c:d", out value));
            Assert.Equal("value1", value);
            Assert.True(provider.TryGet("a", out value));
            Assert.Equal("value2", value);
            Assert.True(provider.TryGet("b", out value));
            Assert.Equal("10", value);

        }