Exemple #1
0
        public FakeFileSystem()
        {
            FileOperation = new FileOperation(
                readFile: file => InputFiles[file.NormalizeDirectorySeparators()],
                writeFile: (file, content) => OutputFiles[file.NormalizeDirectorySeparators()] = content,
                fileExists: file => InputFiles.ContainsKey(file.NormalizeDirectorySeparators()),
                createDirectory: dir => { },
                fileCopy: (source, dest, overwrite) => { });

            // Unfortunately DotLiquid uses a mutable static field for its reference to the root directory.
            // It's fine for non-test scenarios because the root won't change, but it makes unit testing
            // with different roots a bit of a pain. So we define the static field centrally so all unit tests
            // use the same root.
            Template.FileSystem = new NessieLiquidFileSystem(FileOperation, Root);
        }