From ca6e44d496b0c589fdaabad69a00643f539c47cd Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Fri, 14 Feb 2025 22:29:39 -0500 Subject: Convert ext\ to MSTest and traversal projects. - Move ext\ unit tests to MSTest. - MSBuildify ext projects with MSTest execution. - Fork test support projects for MSTest: - WixInternal.TestSupport - WixInternal.Core.TestPackage --- .../TestDataFolderFileSystem.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/internal/WixInternal.MSTestSupport/TestDataFolderFileSystem.cs (limited to 'src/internal/WixInternal.MSTestSupport/TestDataFolderFileSystem.cs') diff --git a/src/internal/WixInternal.MSTestSupport/TestDataFolderFileSystem.cs b/src/internal/WixInternal.MSTestSupport/TestDataFolderFileSystem.cs new file mode 100644 index 00000000..1fea9665 --- /dev/null +++ b/src/internal/WixInternal.MSTestSupport/TestDataFolderFileSystem.cs @@ -0,0 +1,42 @@ +// 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. + +namespace WixInternal.MSTestSupport +{ + using System; + + /// + /// This class builds on top of DisposableFileSystem + /// to make it easy to write a test that needs a whole folder of test data copied to a temp location + /// that will automatically be cleaned up at the end of the test. + /// + public class TestDataFolderFileSystem : IDisposable + { + private DisposableFileSystem fileSystem; + + public string BaseFolder { get; private set; } + + public void Dispose() + { + this.fileSystem?.Dispose(); + } + + public void Initialize(string sourceDirectoryPath) + { + if (this.fileSystem != null) + { + throw new InvalidOperationException(); + } + this.fileSystem = new DisposableFileSystem(); + + this.BaseFolder = this.fileSystem.GetFolder(); + + RobocopyFolder(sourceDirectoryPath, this.BaseFolder); + } + + public static ExternalExecutableResult RobocopyFolder(string sourceFolderPath, string destinationFolderPath) + { + var args = $"\"{sourceFolderPath}\" \"{destinationFolderPath}\" /E /R:1 /W:1"; + return RobocopyRunner.Execute(args); + } + } +} -- cgit v1.2.3-55-g6feb