public void Save_UpdatesInMemoryConfigSoNextLoadWillDeliverThatConfig() { using (var fn = TestFileName.Create(nameof(Save_UpdatesInMemoryConfigSoNextLoadWillDeliverThatConfig), "file", Toml.FileExtension)) { // Arrange var fc = new FileConfig(new FileConfigSource(fn)); var oc = new ReloadOnExternalChangeFileConfig(fc); File.WriteAllText(fn, "X = 1"); oc.Load(); // At least one load needs to be done, otherwise a load will be done because not any data was loaded yet // Act oc.Save(Toml.ReadString("X = 2")); // Assert var readBack = oc.Load(); ((TomlInt)readBack["X"]).Value.Should().Be(2); } }
public void Save_UpdatesInMemoryConfigSoNextLoadWillDeliverThatConfig() { using (var fn = TestFileName.Create("file", Toml.FileExtension)) { // Arrange var fc = new FileConfigStore(TomlSettings.DefaultInstance, fn, fn); var oc = new ReloadOnExternalChangeFileConfig(fc); File.WriteAllText(fn, "X = 1"); oc.Load(); // At least one load needs to be done, otherwise a load will be done because not any data was loaded yet // Act oc.Save(Toml.ReadString("X = 2")); // Assert var readBack = oc.Load(); ((TomlInt)readBack["X"]).Value.Should().Be(2); } }