public void FromFilesTest()
        {
            var fileSystem = new MockFileSystemEx();

            fileSystem.AddFile(@"c:\temp\data0.config", new MockFileData("{\"Text\":\"DemoDataValue0\"}"));
            fileSystem.AddFile(@"c:\temp\data1.config", new MockFileData("{\"Text\":\"DemoDataValue1\"}"));

            fileSystem.Install();

            var sources =
                JsonConfigurationSource <DemoSetting> .FromFiles(new[]
                                                                 { @"c:\temp\data0.config", @"c:\temp\data1.config" }).ToArray();

            Assert.Equal(2, sources.Length);
            Assert.Contains("DemoDataValue0", sources.Select(source => (source.GetSettingObject() as DemoSetting)?.Text));
            Assert.Contains("DemoDataValue1", sources.Select(source => (source.GetSettingObject() as DemoSetting)?.Text));
        }
        private static void InstallDemoFileSys()
        {
            var fileSystem = new MockFileSystemEx();

            fileSystem.AddFile(@"c:\temp\data.config",
                               new MockFileData("{\"Text\":\"DemoDataValue\"}"));

            fileSystem.Install();
        }
Beispiel #3
0
        public void Read_WithFileName_ReturnsFileContent()
        {
            const string fileContent = "public void Test(){}";
            const string fileName    = @"c:\temp\test.cs";

            var fileSystem = new MockFileSystemEx();

            fileSystem.AddFile(fileName, new MockFileData(fileContent));
            fileSystem.Install();

            var sourceCode = new FileSourceCode(fileName);

            Assert.Equal(fileContent, sourceCode.Read());
        }