public async Task CreateConfigTest()
        {
            const string name        = "Kurt test";
            const string description = "Kurt's test config from test proj";

            CreateConfig newConfig = new CreateConfig
            {
                Name        = name,
                Description = description,
                Settings    = new List <Setting>
                {
                    new Setting
                    {
                        Key   = "Hello",
                        Value = "Bye 馃憢"
                    }
                }
            };

            ConfigWithSettingsList config = await _remoteConfigsRepo.CreateConfigAsync(newConfig);

            Assert.NotNull(config);
            Assert.AreEqual(config.Name, name);
            Assert.AreEqual(config.Description, description);
            Assert.NotNull(config.Settings);
            Assert.NotZero(config.Settings.Count);
            Assert.AreEqual(config.Settings.Count, 1);
            Assert.Pass();
        }
        public async Task UpdateConfigTest(string uniqueId)
        {
            const string name        = "Kurt test updated";
            const string description = "Kurt's test config updated from test proj";

            UpdateConfig newConfig = new UpdateConfig
            {
                Name        = name,
                Description = description,
                Settings    = new List <Setting>
                {
                    new Setting
                    {
                        Key   = "Bye bye",
                        Value = "Hello 馃憢"
                    }
                }
            };

            ConfigWithSettingsList config = await _remoteConfigsRepo.UpdateConfigAsync(uniqueId, newConfig);

            Assert.NotNull(config);
            Assert.AreEqual(config.Name, name);
            Assert.AreEqual(config.Description, description);
            Assert.NotNull(config.Settings);
            Assert.NotZero(config.Settings.Count);
            Assert.AreEqual(config.Settings.Count, 1);
            Assert.Pass();
        }
        public async Task GetSpecificConfigTest(string uniqueId)
        {
            ConfigWithSettingsList config = await _remoteConfigsRepo.GetConfigAsync(uniqueId);

            Assert.NotNull(config);
            Assert.NotNull(config.Settings);
            Assert.NotZero(config.Settings.Count);
            Assert.Pass();
        }
Example #4
0
        public async Task <ConfigWithSettingsList> GetConfigAsync(string uniqueId)
        {
            string configurationUrl = Path.Combine(_configurationsUrl, uniqueId);

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add(HeaderKey, _apiKey);
                HttpResponseMessage response = await client.GetAsync(configurationUrl);

                string content = await response.Content.ReadAsStringAsync();

                ConfigWithSettingsList config = JsonConvert.DeserializeObject <ConfigWithSettingsList>(content);
                return(config);
            }
        }
Example #5
0
        public async Task <ConfigWithSettingsList> UpdateConfigAsync(string uniqueId, UpdateConfig updatedConfig)
        {
            string configurationUrl = Path.Combine(_configurationsUrl, uniqueId);

            string payload = JsonConvert.SerializeObject(updatedConfig);

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add(HeaderKey, _apiKey);
                HttpResponseMessage response = await client.PutAsync(configurationUrl, new StringContent(payload, Encoding.UTF8, "application/json"));

                string content = await response.Content.ReadAsStringAsync();

                ConfigWithSettingsList config = JsonConvert.DeserializeObject <ConfigWithSettingsList>(content);
                return(config);
            }
        }