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"))); }
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"))); }
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); }
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); }
public void ShouldSetMetadata() { // Given CopyFiles copyFiles = new CopyFiles("**/test-a.txt"); // When copyFiles.Execute(Inputs, Context).ToList(); }
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); }
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 }
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")); }