예제 #1
0
            public void CopyFolderFromAboveInputPath()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input\";
                engine.OutputFolder = @"TestFiles\Output\";
                engine.CleanOutputPath();

                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument("Test") };
                CopyFiles copyFiles = new CopyFiles("../*.txt").FromTopDirectoryOnly();

                // When
                IEnumerable<IDocument> outputs = copyFiles.Execute(inputs, context).ToList();
                foreach (IDocument document in inputs.Concat(outputs))
                {
                    ((IDisposable) document).Dispose();
                }

                // Then
                Assert.IsFalse(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-a.txt")));
                Assert.IsFalse(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-b.txt")));
                Assert.IsFalse(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory,
                        @"TestFiles\Output\Subfolder\test-c.txt")));
                Assert.IsTrue(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory,
                        @"TestFiles\Output\test-above-input.txt")));
            }
예제 #2
0
        public void CopyWithSearchPatternRecursive()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.RootFolder = TestContext.CurrentContext.TestDirectory;
            engine.InputFolder= @"TestFiles\Input\";
            engine.OutputFolder = @"TestFiles\Output\";

            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline).Clone("Test") };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            CopyFiles copyFiles = new CopyFiles("*.txt");

            // When
            IEnumerable<IDocument> outputs = copyFiles.Execute(inputs, context).ToList();
            foreach (IDocument document in inputs.Concat(outputs))
            {
                ((IDisposable)document).Dispose();
            }

            // Then
            Assert.IsTrue(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-a.txt")));
            Assert.IsTrue(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-b.txt")));
            Assert.IsTrue(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\Subfolder\test-c.txt")));
            Assert.IsFalse(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\markdown-x.md")));
            Assert.IsFalse(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\Subfolder\markdown-y.md")));
        }
예제 #3
0
            public void RecursivePatternCopiesFiles()
            {
                // Given
                CopyFiles copyFiles = new CopyFiles("**/*.txt");

                // When
                copyFiles.Execute(Inputs, Context).ToList();

                // Then
                Assert.IsTrue(Engine.FileSystem.GetOutputFile("test-a.txt").Exists);
                Assert.IsTrue(Engine.FileSystem.GetOutputFile("test-b.txt").Exists);
                Assert.IsTrue(Engine.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists);
                Assert.IsTrue(Engine.FileSystem.GetOutputDirectory("Subfolder").Exists);
                Assert.IsFalse(Engine.FileSystem.GetOutputFile("markdown-x.md").Exists);
                Assert.IsFalse(Engine.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists);
            }
예제 #4
0
            public void ShouldSetFilePathMetadata(string key, string expected)
            {
                // Given
                CopyFiles copyFiles = new CopyFiles("**/test-a.txt");

                // When
                IDocument output = copyFiles.Execute(Inputs, Context).ToList().First();

                // Then
                object result = output[key];
                Assert.IsInstanceOf<FilePath>(result);
                Assert.AreEqual(expected, ((FilePath)result).FullPath);
            }
예제 #5
0
            public void ShouldSetMetadata()
            {
                // Given
                CopyFiles copyFiles = new CopyFiles("**/test-a.txt");

                // When
                copyFiles.Execute(Inputs, Context).ToList();

            }
예제 #6
0
            public void CopyFilesAboveInputPathWithOthers()
            {
                // Given
                CopyFiles copyFiles = new CopyFiles("../**/*.txt");

                // When
                copyFiles.Execute(Inputs, Context).ToList();

                // Then
                Assert.IsTrue(Engine.FileSystem.GetOutputFile("test-a.txt").Exists);
                Assert.IsTrue(Engine.FileSystem.GetOutputFile("test-b.txt").Exists);
                Assert.IsTrue(Engine.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists);
                Assert.IsTrue(Engine.FileSystem.GetOutputDirectory("Subfolder").Exists);
                Assert.IsFalse(Engine.FileSystem.GetOutputFile("markdown-x.md").Exists);
                Assert.IsFalse(Engine.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists);
                Assert.IsTrue(Engine.FileSystem.GetOutputFile("test-above-input.txt").Exists);
            }
예제 #7
0
            public void CopyNonExistentFolder()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input\";
                engine.OutputFolder = @"TestFiles\Output\";
                engine.CleanOutputPath();

                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument("Test") };
                CopyFiles copyFiles = new CopyFiles("NonExistent\\*.txt");

                // When
                IEnumerable<IDocument> outputs = copyFiles.Execute(inputs, context).ToList();
                foreach (IDocument document in inputs.Concat(outputs))
                {
                    ((IDisposable) document).Dispose();
                }

                // Then
                // No exception should be thrown
            }
예제 #8
0
        public void CopyFolderFromAbsolutePath()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.InputFolder = @"TestFiles\Input\";
            engine.OutputFolder = @"TestFiles\Output\";

            string absoluteInputPath = Path.GetFullPath(engine.InputFolder);

            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline).Clone("Test") };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            CopyFiles copyFiles = new CopyFiles(Path.Combine(absoluteInputPath, "*.txt")).FromTopDirectoryOnly();

            // When
            IEnumerable<IDocument> outputs = copyFiles.Execute(inputs, context).ToList();
            foreach (IDocument document in inputs.Concat(outputs))
            {
                ((IDisposable)document).Dispose();
            }

            // Then
            Assert.IsTrue(File.Exists(@"TestFiles\Output\test-a.txt"));
            Assert.IsTrue(File.Exists(@"TestFiles\Output\test-b.txt"));
            Assert.IsFalse(File.Exists(@"TestFiles\Output\Subfolder\test-c.txt"));
            Assert.IsFalse(File.Exists(@"TestFiles\Output\test-above-input.txt"));
        }