Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }