From aa0bd9f66dabc6460f93cf9a029e06b079f10db8 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 20:00:30 -0700 Subject: Move Core.Native into wix --- .../WixToolsetTest.Core.Native/CabinetFixture.cs | 96 --------------------- src/test/WixToolsetTest.Core.Native/MsmFixture.cs | 17 ---- .../WixToolsetTest.Core.Native/TestData/test.cab | Bin 115 -> 0 bytes .../WixToolsetTest.Core.Native/TestData/test.txt | 1 - .../Utility/DisposableFileSystem.cs | 86 ------------------ .../WixToolsetTest.Core.Native/Utility/Pushd.cs | 46 ---------- .../WixToolsetTest.Core.Native/Utility/TestData.cs | 17 ---- .../WixToolsetTest.Core.Native.csproj | 26 ------ src/test/version.txt | 1 - 9 files changed, 290 deletions(-) delete mode 100644 src/test/WixToolsetTest.Core.Native/CabinetFixture.cs delete mode 100644 src/test/WixToolsetTest.Core.Native/MsmFixture.cs delete mode 100644 src/test/WixToolsetTest.Core.Native/TestData/test.cab delete mode 100644 src/test/WixToolsetTest.Core.Native/TestData/test.txt delete mode 100644 src/test/WixToolsetTest.Core.Native/Utility/DisposableFileSystem.cs delete mode 100644 src/test/WixToolsetTest.Core.Native/Utility/Pushd.cs delete mode 100644 src/test/WixToolsetTest.Core.Native/Utility/TestData.cs delete mode 100644 src/test/WixToolsetTest.Core.Native/WixToolsetTest.Core.Native.csproj delete mode 100644 src/test/version.txt (limited to 'src/test') diff --git a/src/test/WixToolsetTest.Core.Native/CabinetFixture.cs b/src/test/WixToolsetTest.Core.Native/CabinetFixture.cs deleted file mode 100644 index 2e43dce4..00000000 --- a/src/test/WixToolsetTest.Core.Native/CabinetFixture.cs +++ /dev/null @@ -1,96 +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 WixToolsetTest.CoreNative -{ - using System.IO; - using System.Linq; - using WixToolset.Core.Native; - using WixToolsetTest.CoreNative.Utility; - using WixToolset.Data; - using Xunit; - - public class CabinetFixture - { - [Fact] - public void CanCreateSingleFileCabinet() - { - using (var fs = new DisposableFileSystem()) - { - var intermediateFolder = fs.GetFolder(true); - var cabPath = Path.Combine(intermediateFolder, "testout.cab"); - - var files = new[] { new CabinetCompressFile(TestData.Get(@"TestData\test.txt"), "test.txt") }; - - var cabinet = new Cabinet(cabPath); - cabinet.Compress(files, CompressionLevel.Low); - - Assert.True(File.Exists(cabPath)); - } - } - - [Fact] - public void CanEnumerateSingleFileCabinet() - { - var cabinetPath = TestData.Get(@"TestData\test.cab"); - - var cabinet = new Cabinet(cabinetPath); - var files = cabinet.Enumerate(); - - var file = files.Single(); - Assert.Equal("test.txt", file.FileId); - Assert.Equal(17, file.Size); - - Assert.Equal(19259, file.Date); - Assert.Equal(47731, file.Time); - // TODO: This doesn't seem to always pass, not clear why but it'd be good to understand one day. - // Assert.True(file.SameAsDateTime(new DateTime(2017, 9, 28, 0, 19, 38))); - } - - [Fact] - public void IntegrationTest() - { - using (var fs = new DisposableFileSystem()) - { - var intermediateFolder = fs.GetFolder(true); - var cabinetPath = Path.Combine(intermediateFolder, "testout.cab"); - var extractFolder = fs.GetFolder(true); - - // Compress. - { - var files = new[] { - new CabinetCompressFile(TestData.Get(@"TestData\test.txt"), "test1.txt"), - new CabinetCompressFile(TestData.Get(@"TestData\test.txt"), "test2.txt"), - }; - - var cabinet = new Cabinet(cabinetPath); - cabinet.Compress(files, CompressionLevel.Low); - } - - // Extract. - { - var cabinet = new Cabinet(cabinetPath); - var reportedFiles = cabinet.Extract(extractFolder); - Assert.Equal(2, reportedFiles.Count()); - } - - // Enumerate to compare cabinet to extracted files. - { - var cabinet = new Cabinet(cabinetPath); - var enumerated = cabinet.Enumerate().OrderBy(f => f.FileId).ToArray(); - - var files = Directory.EnumerateFiles(extractFolder).OrderBy(f => f).ToArray(); - - for (var i = 0; i < enumerated.Length; ++i) - { - var cabFileInfo = enumerated[i]; - var fileInfo = new FileInfo(files[i]); - - Assert.Equal(cabFileInfo.FileId, fileInfo.Name); - Assert.Equal(cabFileInfo.Size, fileInfo.Length); - Assert.True(cabFileInfo.SameAsDateTime(fileInfo.CreationTime)); - } - } - } - } - } -} diff --git a/src/test/WixToolsetTest.Core.Native/MsmFixture.cs b/src/test/WixToolsetTest.Core.Native/MsmFixture.cs deleted file mode 100644 index 709d4b93..00000000 --- a/src/test/WixToolsetTest.Core.Native/MsmFixture.cs +++ /dev/null @@ -1,17 +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 WixToolsetTest.CoreNative -{ - using WixToolset.Core.Native.Msm; - using Xunit; - - public class MsmFixture - { - [Fact] - public void CanCreateMsmInterface() - { - var merge = MsmInterop.GetMsmMerge(); - Assert.NotNull(merge); - } - } -} diff --git a/src/test/WixToolsetTest.Core.Native/TestData/test.cab b/src/test/WixToolsetTest.Core.Native/TestData/test.cab deleted file mode 100644 index ca78f632..00000000 Binary files a/src/test/WixToolsetTest.Core.Native/TestData/test.cab and /dev/null differ diff --git a/src/test/WixToolsetTest.Core.Native/TestData/test.txt b/src/test/WixToolsetTest.Core.Native/TestData/test.txt deleted file mode 100644 index cd0db0e1..00000000 --- a/src/test/WixToolsetTest.Core.Native/TestData/test.txt +++ /dev/null @@ -1 +0,0 @@ -This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Core.Native/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.Core.Native/Utility/DisposableFileSystem.cs deleted file mode 100644 index c9957247..00000000 --- a/src/test/WixToolsetTest.Core.Native/Utility/DisposableFileSystem.cs +++ /dev/null @@ -1,86 +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 WixToolsetTest.CoreNative.Utility -{ - using System; - using System.Collections.Generic; - using System.IO; - - public class DisposableFileSystem : IDisposable - { - protected bool Disposed { get; private set; } - - private List CleanupPaths { get; } = new List(); - - public string GetFile(bool create = false) - { - var path = Path.GetTempFileName(); - - if (!create) - { - File.Delete(path); - } - - this.CleanupPaths.Add(path); - - return path; - } - - public string GetFolder(bool create = false) - { - var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - - if (create) - { - Directory.CreateDirectory(path); - } - - this.CleanupPaths.Add(path); - - return path; - } - - - #region // IDisposable - - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (this.Disposed) - { - return; - } - - if (disposing) - { - foreach (var path in this.CleanupPaths) - { - try - { - if (File.Exists(path)) - { - File.Delete(path); - } - else if (Directory.Exists(path)) - { - Directory.Delete(path, true); - } - } - catch - { - // Best effort delete, so ignore any failures. - } - } - } - - this.Disposed = true; - } - - #endregion - } -} diff --git a/src/test/WixToolsetTest.Core.Native/Utility/Pushd.cs b/src/test/WixToolsetTest.Core.Native/Utility/Pushd.cs deleted file mode 100644 index 91700c2f..00000000 --- a/src/test/WixToolsetTest.Core.Native/Utility/Pushd.cs +++ /dev/null @@ -1,46 +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 WixToolsetTest.CoreNative.Utility -{ - using System; - using System.IO; - - public class Pushd : IDisposable - { - protected bool Disposed { get; private set; } - - public Pushd(string path) - { - this.PreviousDirectory = Directory.GetCurrentDirectory(); - - Directory.SetCurrentDirectory(path); - } - - public string PreviousDirectory { get; } - - #region // IDisposable - - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (this.Disposed) - { - return; - } - - if (disposing) - { - Directory.SetCurrentDirectory(this.PreviousDirectory); - } - - this.Disposed = true; - } - - #endregion - } -} diff --git a/src/test/WixToolsetTest.Core.Native/Utility/TestData.cs b/src/test/WixToolsetTest.Core.Native/Utility/TestData.cs deleted file mode 100644 index cd9c6318..00000000 --- a/src/test/WixToolsetTest.Core.Native/Utility/TestData.cs +++ /dev/null @@ -1,17 +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 WixToolsetTest.CoreNative.Utility -{ - using System; - using System.IO; - - public class TestData - { - public static string LocalPath => Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); - - public static string Get(params string[] paths) - { - return Path.Combine(LocalPath, Path.Combine(paths)); - } - } -} diff --git a/src/test/WixToolsetTest.Core.Native/WixToolsetTest.Core.Native.csproj b/src/test/WixToolsetTest.Core.Native/WixToolsetTest.Core.Native.csproj deleted file mode 100644 index 6068dbea..00000000 --- a/src/test/WixToolsetTest.Core.Native/WixToolsetTest.Core.Native.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - netcoreapp3.1 - false - win-x64 - - - - - - - - - - - - - - - - - - diff --git a/src/test/version.txt b/src/test/version.txt deleted file mode 100644 index cf138743..00000000 --- a/src/test/version.txt +++ /dev/null @@ -1 +0,0 @@ -v42.42.{height}-preview.0 \ No newline at end of file -- cgit v1.2.3-55-g6feb