aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-05-30 12:17:13 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-05-30 23:06:26 +1000
commitc70de8284987e4977ee40133180a1b220a68da71 (patch)
tree609593f7dd9c8199eb38d2f2490b03240ec310ca /src
parent223b2845955d4d6604cfd014cf9aa536ca1eb0a2 (diff)
downloadwix-c70de8284987e4977ee40133180a1b220a68da71.tar.gz
wix-c70de8284987e4977ee40133180a1b220a68da71.tar.bz2
wix-c70de8284987e4977ee40133180a1b220a68da71.zip
Add TestDataFolderFileSystem.
Diffstat (limited to 'src')
-rw-r--r--src/WixBuildTools.TestSupport/RobocopyRunner.cs16
-rw-r--r--src/WixBuildTools.TestSupport/TestDataFolderFileSystem.cs42
2 files changed, 58 insertions, 0 deletions
diff --git a/src/WixBuildTools.TestSupport/RobocopyRunner.cs b/src/WixBuildTools.TestSupport/RobocopyRunner.cs
new file mode 100644
index 00000000..49d53351
--- /dev/null
+++ b/src/WixBuildTools.TestSupport/RobocopyRunner.cs
@@ -0,0 +1,16 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixBuildTools.TestSupport
4{
5 public class RobocopyRunner : ExternalExecutable
6 {
7 private static readonly RobocopyRunner Instance = new RobocopyRunner();
8
9 private RobocopyRunner() : base("robocopy") { }
10
11 public static ExternalExecutableResult Execute(string args)
12 {
13 return Instance.Run(args);
14 }
15 }
16}
diff --git a/src/WixBuildTools.TestSupport/TestDataFolderFileSystem.cs b/src/WixBuildTools.TestSupport/TestDataFolderFileSystem.cs
new file mode 100644
index 00000000..8d670bf0
--- /dev/null
+++ b/src/WixBuildTools.TestSupport/TestDataFolderFileSystem.cs
@@ -0,0 +1,42 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixBuildTools.TestSupport
4{
5 using System;
6
7 /// <summary>
8 /// This class builds on top of DisposableFileSystem
9 /// to make it easy to write a test that needs a whole folder of test data copied to a temp location
10 /// that will automatically be cleaned up at the end of the test.
11 /// </summary>
12 public class TestDataFolderFileSystem : IDisposable
13 {
14 private DisposableFileSystem fileSystem;
15
16 public string BaseFolder { get; private set; }
17
18 public void Dispose()
19 {
20 this.fileSystem?.Dispose();
21 }
22
23 public void Initialize(string sourceDirectoryPath)
24 {
25 if (this.fileSystem != null)
26 {
27 throw new InvalidOperationException();
28 }
29 this.fileSystem = new DisposableFileSystem();
30
31 this.BaseFolder = this.fileSystem.GetFolder();
32
33 RobocopyFolder(sourceDirectoryPath, this.BaseFolder);
34 }
35
36 private static ExternalExecutableResult RobocopyFolder(string sourceFolderPath, string destinationFolderPath)
37 {
38 var args = $"\"{sourceFolderPath}\" \"{destinationFolderPath}\" /E /R:1 /W:1";
39 return RobocopyRunner.Execute(args);
40 }
41 }
42}