public async Task ReadFile_NotExist_Should_Return_Default() { var simpleConfig = CreateSimpleConfigFile(); var defaultValue = new SimpleConfig(); var config = await simpleConfig.ReadFile("not_exist.json", defaultValue); config.ShouldSame(defaultValue); }
public async Task ReadFile_Exist_Should_Return_It() { var simpleConfig = CreateSimpleConfigFile(); var defaultValue = new SimpleConfig(); var config = await simpleConfig.ReadFile("exist.json", defaultValue); config.ShouldNotSame(defaultValue); config.TryGet("key1", 0).ShouldEqual(1); config.TryGet("key2", "").ShouldEqual("2"); config.TryGet("key3", new DateTime(1999, 1, 1)).ShouldEqual(new DateTime(2000, 1, 1)); }
private ISimpleConfigFile CreateSimpleConfigFile() { var mockJsonFile = new MockJsonFile(); var mockConfig = new SimpleConfig(); mockConfig.AddOrUpdate("key1", 1); mockConfig.AddOrUpdate("key2", "2"); mockConfig.AddOrUpdate("key3", new DateTime(2000, 1, 1)); mockJsonFile.MockConfig = mockConfig; mockJsonFile.MockConfigFilePath = "exist.json"; return(new SimpleConfigFile(mockJsonFile)); }