public void TestExecuteWithActionMove([Values( V2.DirectoryOperationsShared.ExistsOption.DoNothing, V2.DirectoryOperationsShared.ExistsOption.OverwriteDirectory, V2.DirectoryOperationsShared.ExistsOption.MergeDirectory )] V2.DirectoryOperationsShared.ExistsOption fileExistsOption, [Values(true, false)] bool replaceExistingFiles) { CreateTargetDirectory(fixtureTargetFolderPath, false); TestExecuteWithActionMove(fixtureSourceDirectoryPath, fixtureTargetFolderPath, fileExistsOption, replaceExistingFiles); }
private FunctionResult Execute(V2.DirectoryOperationsShared.ActionType action, string sourceDirectoryPath = null, string targetDirectoryPath = null, V2.DirectoryOperationsShared.ExistsOption existsOption = V2.DirectoryOperationsShared.ExistsOption.DoNothing, V2.DirectoryOperationsShared.CreateExistsOption createExistsOption = V2.DirectoryOperationsShared.CreateExistsOption.DoNothing, string directory = null, bool replaceIfFileExist = false) { FunctionExecutor tester = (new FunctionTester <DirectoryOperations>()).Compile( new PropertyValue(DirectoryOperationsShared.ActionPropertyName, action), new PropertyValue(DirectoryOperationsShared.ReplaceExistingFilePropertyName, replaceIfFileExist), new PropertyValue(DirectoryOperationsShared.DirectoryExistsPropertyName, existsOption), new PropertyValue(DirectoryOperationsShared.CreateDirectoryExistsPropertyName, createExistsOption)); return(tester.Execute( new ParameterValue(DirectoryOperationsShared.SourceDirectoryPropertyName, sourceDirectoryPath), new ParameterValue(DirectoryOperationsShared.TargetDirectoryPropertyName, targetDirectoryPath), new ParameterValue(DirectoryOperationsShared.DirectoryPropertyName, directory))); }
private void TestExecuteWithActionMove(string sourceDirectoryPath, string targetDirectoryPath, V2.DirectoryOperationsShared.ExistsOption existsOption, bool replaceFileIfExists) { FunctionResult result = Execute(V2.DirectoryOperationsShared.ActionType.Move, sourceDirectoryPath, targetDirectoryPath, existsOption, replaceIfFileExist: replaceFileIfExists); var targetFolderCount = Directory.GetDirectories(fixtureTargetFolderPath, "*", SearchOption.AllDirectories).Count(); var targetFileCount = Directory.GetFiles(fixtureTargetFolderPath, "*", SearchOption.AllDirectories).Count(); if (existsOption == V2.DirectoryOperationsShared.ExistsOption.DoNothing) { Assert.AreEqual(fixtureTargetDirectoryCount, targetFolderCount, "The folder count should be same"); Assert.AreEqual(fixtureTargetFileCount, targetFileCount, "The file count should be same"); } else { if (!replaceFileIfExists) { Assert.AreEqual(fixtureSourceDirectoryCount, targetFolderCount, "Source folder count and target folder count should match."); Assert.AreEqual(fixtureSourceFileCount, targetFileCount, "Source file count and target file count should match."); } else { Assert.IsFalse(Directory.Exists(fixtureSourceDirectoryPath), "The source directory should be deleted."); Assert.AreEqual(fixtureSourceDirectoryCount, targetFolderCount, "Source folder count and target folder count should match."); Assert.AreEqual(fixtureSourceFileCount, targetFileCount, "Source file count and target file count should match."); } } }
private void TestExecuteWithActionCopy(string sourceDirectoryPath, string targetDirectoryPath, V2.DirectoryOperationsShared.ExistsOption existsOption, bool replaceFileIfExists) { FunctionResult result = Execute(V2.DirectoryOperationsShared.ActionType.Copy, sourceDirectoryPath, targetDirectoryPath, existsOption, replaceIfFileExist: replaceFileIfExists); Assert.IsTrue(System.IO.Directory.Exists(sourceDirectoryPath)); Assert.IsTrue(System.IO.Directory.Exists(Path.Combine(targetDirectoryPath, "Source")), "Target directory does not exist."); var sourceFolderCount = Directory.GetDirectories(fixtureSourceDirectoryPath, "*", SearchOption.AllDirectories).Count(); var targetFolderCount = Directory.GetDirectories(Path.Combine(fixtureTargetFolderPath, "Source"), "*", SearchOption.AllDirectories).Count(); var sourceFileCount = Directory.GetFiles(fixtureSourceDirectoryPath, "*", SearchOption.AllDirectories).Count(); var targetFileCount = Directory.GetFiles(Path.Combine(fixtureTargetFolderPath, "Source"), "*", SearchOption.AllDirectories).Count(); if (existsOption == V2.DirectoryOperationsShared.ExistsOption.DoNothing) { Assert.AreEqual(fixtureTargetDirectoryCount, targetFolderCount, "The folder count should be same"); Assert.AreEqual(fixtureTargetFileCount, targetFileCount, "The file count should be same"); } else { Assert.AreEqual(sourceFolderCount, targetFolderCount, "Source folder count and target folder count should match."); Assert.AreEqual(sourceFileCount, targetFileCount, "Source file count and target file count should match."); } }