public void ShouldCreateSubFiles()
        {
            var rootPath = SampleData.GenerateRandomTempPath("FileHierarchyBuilderTests");

            var builder = new FileHierarchyBuilder(rootPath);
            builder.AddFiles(new[] { new FileNode("RootFile01.txt", "Contents of root file 01") })
                .AddDirectory("SubDirectory")
                .AddFiles(
                    new[]
                        {
                            new FileNode("File01.txt", "Contents of file 01"),
                            new FileNode("File02.txt", "Contents of file 02")
                        });

            builder.Execute(this.FileSystem);

            var pathToRootFile1 = Path.Combine(rootPath, "RootFile01.txt");
            var pathToFile1 = Path.Combine(rootPath, "SubDirectory", "File01.txt");
            var pathToFile2 = Path.Combine(rootPath, "SubDirectory", "File02.txt");

            File.Exists(pathToRootFile1).ShouldBe(true, string.Format("File doesn't exist: {0}", pathToRootFile1));
            File.Exists(pathToFile1).ShouldBe(true, string.Format("File doesn't exist: {0}", pathToFile1));
            File.Exists(pathToFile2).ShouldBe(true, string.Format("File doesn't exist: {0}", pathToFile2));

            var file1Contents = this.FileSystem.LoadFile(pathToFile1);
            file1Contents.ShouldBe("Contents of file 01");
        }
예제 #2
0
        public static void CreateSampleFileHierarchy(IFileSystem fileSystem, string rootPath)
        {
            var builder = new FileHierarchyBuilder(rootPath);

            builder.AddFiles(
                new[]
            {
                new FileNode("ATextFile.txt", "Some contents"),
                new FileNode("AnotherTextFile.txt", "Some more contents"),
                new FileNode("Apples.resx", SampleXmlFruitResourceString("Apple")),
                new FileNode("Apples.cs", SampleFruitySourceFile("Apple"))
            })
            .AddDirectory("Directory1")
            .AddFiles(
                new[]
            {
                new FileNode("ASourceFile.cs", @"//Some source code"),
                new FileNode("Oranges.resx", SampleXmlFruitResourceString("Orange")),
                new FileNode("Oranges.cs", SampleFruitySourceFile("Orange"))
            });

            builder.Execute(fileSystem);
        }
예제 #3
0
        public static void CreateSampleFileHierarchy(IFileSystem fileSystem, string rootPath)
        {
            var builder = new FileHierarchyBuilder(rootPath);

            builder.AddFiles(
                new[]
                    {
                        new FileNode("ATextFile.txt", "Some contents"),
                        new FileNode("AnotherTextFile.txt", "Some more contents"),
                        new FileNode("Apples.resx", SampleXmlFruitResourceString("Apple")),
                        new FileNode("Apples.cs", SampleFruitySourceFile("Apple"))
                    })
                .AddDirectory("Directory1")
                .AddFiles(
                    new[]
                        {
                            new FileNode("ASourceFile.cs", @"//Some source code"),
                            new FileNode("Oranges.resx", SampleXmlFruitResourceString("Orange")),
                            new FileNode("Oranges.cs", SampleFruitySourceFile("Orange"))
                        });

            builder.Execute(fileSystem);
        }