From c843b47d6233153fa961c6d0e61edf7cedf255bb Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 8 Nov 2022 14:58:05 -0800 Subject: Separate WixInternal content from official WixToolset namespace --- src/internal/WixBuildTools.TestSupport/TestData.cs | 78 ---------------------- 1 file changed, 78 deletions(-) delete mode 100644 src/internal/WixBuildTools.TestSupport/TestData.cs (limited to 'src/internal/WixBuildTools.TestSupport/TestData.cs') diff --git a/src/internal/WixBuildTools.TestSupport/TestData.cs b/src/internal/WixBuildTools.TestSupport/TestData.cs deleted file mode 100644 index fc1ae4cc..00000000 --- a/src/internal/WixBuildTools.TestSupport/TestData.cs +++ /dev/null @@ -1,78 +0,0 @@ -// 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 WixBuildTools.TestSupport -{ - using System; - using System.IO; - using System.Reflection; - using System.Runtime.CompilerServices; - - public class TestData - { - public static void CreateFile(string path, long size, bool fill = false) - { - // Ensure the directory exists. - path = Path.GetFullPath(path); - Directory.CreateDirectory(Path.GetDirectoryName(path)); - - using (var file = File.OpenWrite(path)) - { - if (fill) - { - var random = new Random(); - var bytes = new byte[4096]; - var generated = 0L; - - // Put fill bytes in the file so it doesn't compress trivially. - while (generated < size) - { - var generate = (int)Math.Min(size - generated, bytes.Length); - - random.NextBytes(bytes); - - file.Write(bytes, 0, generate); - - generated += generate; - } - } - else - { - file.SetLength(size); - } - } - } - - public static string Get(params string[] paths) - { - var localPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath); - return Path.Combine(localPath, Path.Combine(paths)); - } - - public static string GetUnitTestLogsFolder([CallerFilePath] string path = "", [CallerMemberName] string method = "") - { - var startingPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath); - var buildPath = startingPath; - - while (!String.IsNullOrEmpty(buildPath)) - { - var folderName = Path.GetFileName(buildPath); - if (String.Equals("build", folderName, StringComparison.OrdinalIgnoreCase)) - { - break; - } - - buildPath = Path.GetDirectoryName(buildPath); - } - - if (String.IsNullOrEmpty(buildPath)) - { - throw new InvalidOperationException($"Could not find the 'build' folder in the test path: {startingPath}. Cannot get test logs folder without being able to find the build folder."); - } - - var testLogsFolder = Path.Combine(buildPath, "logs", "UnitTests", $"{Path.GetFileNameWithoutExtension(path)}_{method}"); - Directory.CreateDirectory(testLogsFolder); - - return testLogsFolder; - } - } -} -- cgit v1.2.3-55-g6feb