Пример #1
0
		public void TestCopyFileSet()
		{
			string testOutput = Path.Combine(TestFilesPath, @"TestCopyFileSet\TestResult");
			DeleteOutput(testOutput);

			try
			{
				string sourceRoot = Path.Combine(TestFilesPath, @"TestCopyFileSet");
				const string sourceDirectory = "Root";
				string targetRoot = Path.Combine(TestFilesPath, @"TestCopyFileSet");
				const string targetDirectory = "TestResult";
				string[] includes = new[] 
										{
											"*.policy", 
											"*.runtimepolicy"
										};
				string[] excludes = new[]
				                    	{
				                    		"Professional5.policy", 
											"Professional5.runtimepolicy", 
											"WorkshareInternal.runtimepolicy",
				                    		"Send And Protect.runtimepolicy"
				                    	};

				ActionCopyFiles actionCopyFiles = GetActionCopyFiles(sourceRoot, sourceDirectory, targetRoot, targetDirectory,
				                                                     includes, excludes);
				CopyFilesAction copyFileAction = new CopyFilesAction(actionCopyFiles);
				copyFileAction.Execute();

				DirectoryInfo testResultDirectory = new DirectoryInfo(testOutput);
				int filesCopied = testResultDirectory.GetFiles("*.*", SearchOption.AllDirectories).Length;
				Assert.AreEqual(12, filesCopied);
			}
			finally
			{
				DeleteOutput(testOutput);
			}
		}
Пример #2
0
		private void ExecuteCopyFileAction(Action action)
		{
			try
			{
				if (action == null ||
					action.CopyFiles == null)
				{
					return;
				}

				foreach (ActionCopyFiles actionItem in action.CopyFiles)
				{
					if (actionItem == null)
					{
						return;
					}

					CopyFilesAction copyFiles = new CopyFilesAction(actionItem);
					copyFiles.Execute();
				}
			}
			catch (Exception ex)
			{
				Logger.LogError(ex);
			}
		}