public void CommitMethodCanHandleEmptyValue() { var json = @"{ ""key1"": """", ""key2"": { ""key3"": """" } }"; var expectedJson = @"{ ""key1"": ""value1"", ""key2"": { ""key3"": ""value2"" } }"; var jsonConfigSrc = new JsonConfigurationSource(ArbitraryFilePath); var outputCacheStream = new MemoryStream(); jsonConfigSrc.Load(StringToStream(json)); jsonConfigSrc.Set("key1", "value1"); jsonConfigSrc.Set("key2:key3", "value2"); jsonConfigSrc.Commit(StringToStream(json), outputCacheStream); var newContents = StreamToString(outputCacheStream); Assert.Equal(expectedJson, newContents); }
public void CommitMethodUpdatesValues() { var json = @"{ ""name"": ""test"", ""address"": { ""street"": ""Something street"", ""zipcode"": ""12345"" } }"; var jsonConfigSrc = new JsonConfigurationSource(ArbitraryFilePath); var outputCacheStream = new MemoryStream(); jsonConfigSrc.Load(StringToStream(json)); jsonConfigSrc.Set("name", "new_name"); jsonConfigSrc.Set("address:zipcode", "67890"); jsonConfigSrc.Commit(StringToStream(json), outputCacheStream); var newContents = StreamToString(outputCacheStream); Assert.Equal(json.Replace("test", "new_name").Replace("12345", "67890"), newContents); }