diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-22 20:00:30 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-29 16:47:06 -0700 |
| commit | aa0bd9f66dabc6460f93cf9a029e06b079f10db8 (patch) | |
| tree | fd7a3f883a4cc0473e883105eadee3cca668cd68 /src/test | |
| parent | a2f0de28fc0f1ab71d4685c77f0b21d946f3e702 (diff) | |
| download | wix-aa0bd9f66dabc6460f93cf9a029e06b079f10db8.tar.gz wix-aa0bd9f66dabc6460f93cf9a029e06b079f10db8.tar.bz2 wix-aa0bd9f66dabc6460f93cf9a029e06b079f10db8.zip | |
Move Core.Native into wix
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/CabinetFixture.cs | 96 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/MsmFixture.cs | 17 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/TestData/test.cab | bin | 115 -> 0 bytes | |||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/TestData/test.txt | 1 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/Utility/DisposableFileSystem.cs | 86 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/Utility/Pushd.cs | 46 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/Utility/TestData.cs | 17 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Native/WixToolsetTest.Core.Native.csproj | 26 | ||||
| -rw-r--r-- | src/test/version.txt | 1 |
9 files changed, 0 insertions, 290 deletions
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 @@ | |||
| 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 | |||
| 3 | namespace WixToolsetTest.CoreNative | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using System.Linq; | ||
| 7 | using WixToolset.Core.Native; | ||
| 8 | using WixToolsetTest.CoreNative.Utility; | ||
| 9 | using WixToolset.Data; | ||
| 10 | using Xunit; | ||
| 11 | |||
| 12 | public class CabinetFixture | ||
| 13 | { | ||
| 14 | [Fact] | ||
| 15 | public void CanCreateSingleFileCabinet() | ||
| 16 | { | ||
| 17 | using (var fs = new DisposableFileSystem()) | ||
| 18 | { | ||
| 19 | var intermediateFolder = fs.GetFolder(true); | ||
| 20 | var cabPath = Path.Combine(intermediateFolder, "testout.cab"); | ||
| 21 | |||
| 22 | var files = new[] { new CabinetCompressFile(TestData.Get(@"TestData\test.txt"), "test.txt") }; | ||
| 23 | |||
| 24 | var cabinet = new Cabinet(cabPath); | ||
| 25 | cabinet.Compress(files, CompressionLevel.Low); | ||
| 26 | |||
| 27 | Assert.True(File.Exists(cabPath)); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | [Fact] | ||
| 32 | public void CanEnumerateSingleFileCabinet() | ||
| 33 | { | ||
| 34 | var cabinetPath = TestData.Get(@"TestData\test.cab"); | ||
| 35 | |||
| 36 | var cabinet = new Cabinet(cabinetPath); | ||
| 37 | var files = cabinet.Enumerate(); | ||
| 38 | |||
| 39 | var file = files.Single(); | ||
| 40 | Assert.Equal("test.txt", file.FileId); | ||
| 41 | Assert.Equal(17, file.Size); | ||
| 42 | |||
| 43 | Assert.Equal(19259, file.Date); | ||
| 44 | Assert.Equal(47731, file.Time); | ||
| 45 | // TODO: This doesn't seem to always pass, not clear why but it'd be good to understand one day. | ||
| 46 | // Assert.True(file.SameAsDateTime(new DateTime(2017, 9, 28, 0, 19, 38))); | ||
| 47 | } | ||
| 48 | |||
| 49 | [Fact] | ||
| 50 | public void IntegrationTest() | ||
| 51 | { | ||
| 52 | using (var fs = new DisposableFileSystem()) | ||
| 53 | { | ||
| 54 | var intermediateFolder = fs.GetFolder(true); | ||
| 55 | var cabinetPath = Path.Combine(intermediateFolder, "testout.cab"); | ||
| 56 | var extractFolder = fs.GetFolder(true); | ||
| 57 | |||
| 58 | // Compress. | ||
| 59 | { | ||
| 60 | var files = new[] { | ||
| 61 | new CabinetCompressFile(TestData.Get(@"TestData\test.txt"), "test1.txt"), | ||
| 62 | new CabinetCompressFile(TestData.Get(@"TestData\test.txt"), "test2.txt"), | ||
| 63 | }; | ||
| 64 | |||
| 65 | var cabinet = new Cabinet(cabinetPath); | ||
| 66 | cabinet.Compress(files, CompressionLevel.Low); | ||
| 67 | } | ||
| 68 | |||
| 69 | // Extract. | ||
| 70 | { | ||
| 71 | var cabinet = new Cabinet(cabinetPath); | ||
| 72 | var reportedFiles = cabinet.Extract(extractFolder); | ||
| 73 | Assert.Equal(2, reportedFiles.Count()); | ||
| 74 | } | ||
| 75 | |||
| 76 | // Enumerate to compare cabinet to extracted files. | ||
| 77 | { | ||
| 78 | var cabinet = new Cabinet(cabinetPath); | ||
| 79 | var enumerated = cabinet.Enumerate().OrderBy(f => f.FileId).ToArray(); | ||
| 80 | |||
| 81 | var files = Directory.EnumerateFiles(extractFolder).OrderBy(f => f).ToArray(); | ||
| 82 | |||
| 83 | for (var i = 0; i < enumerated.Length; ++i) | ||
| 84 | { | ||
| 85 | var cabFileInfo = enumerated[i]; | ||
| 86 | var fileInfo = new FileInfo(files[i]); | ||
| 87 | |||
| 88 | Assert.Equal(cabFileInfo.FileId, fileInfo.Name); | ||
| 89 | Assert.Equal(cabFileInfo.Size, fileInfo.Length); | ||
| 90 | Assert.True(cabFileInfo.SameAsDateTime(fileInfo.CreationTime)); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | } | ||
| 94 | } | ||
| 95 | } | ||
| 96 | } | ||
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 @@ | |||
| 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 | |||
| 3 | namespace WixToolsetTest.CoreNative | ||
| 4 | { | ||
| 5 | using WixToolset.Core.Native.Msm; | ||
| 6 | using Xunit; | ||
| 7 | |||
| 8 | public class MsmFixture | ||
| 9 | { | ||
| 10 | [Fact] | ||
| 11 | public void CanCreateMsmInterface() | ||
| 12 | { | ||
| 13 | var merge = MsmInterop.GetMsmMerge(); | ||
| 14 | Assert.NotNull(merge); | ||
| 15 | } | ||
| 16 | } | ||
| 17 | } | ||
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 --- a/src/test/WixToolsetTest.Core.Native/TestData/test.cab +++ /dev/null | |||
| Binary files 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 @@ | |||
| 1 | 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 @@ | |||
| 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 | |||
| 3 | namespace WixToolsetTest.CoreNative.Utility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.IO; | ||
| 8 | |||
| 9 | public class DisposableFileSystem : IDisposable | ||
| 10 | { | ||
| 11 | protected bool Disposed { get; private set; } | ||
| 12 | |||
| 13 | private List<string> CleanupPaths { get; } = new List<string>(); | ||
| 14 | |||
| 15 | public string GetFile(bool create = false) | ||
| 16 | { | ||
| 17 | var path = Path.GetTempFileName(); | ||
| 18 | |||
| 19 | if (!create) | ||
| 20 | { | ||
| 21 | File.Delete(path); | ||
| 22 | } | ||
| 23 | |||
| 24 | this.CleanupPaths.Add(path); | ||
| 25 | |||
| 26 | return path; | ||
| 27 | } | ||
| 28 | |||
| 29 | public string GetFolder(bool create = false) | ||
| 30 | { | ||
| 31 | var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
| 32 | |||
| 33 | if (create) | ||
| 34 | { | ||
| 35 | Directory.CreateDirectory(path); | ||
| 36 | } | ||
| 37 | |||
| 38 | this.CleanupPaths.Add(path); | ||
| 39 | |||
| 40 | return path; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | #region // IDisposable | ||
| 45 | |||
| 46 | public void Dispose() | ||
| 47 | { | ||
| 48 | this.Dispose(true); | ||
| 49 | GC.SuppressFinalize(this); | ||
| 50 | } | ||
| 51 | |||
| 52 | protected virtual void Dispose(bool disposing) | ||
| 53 | { | ||
| 54 | if (this.Disposed) | ||
| 55 | { | ||
| 56 | return; | ||
| 57 | } | ||
| 58 | |||
| 59 | if (disposing) | ||
| 60 | { | ||
| 61 | foreach (var path in this.CleanupPaths) | ||
| 62 | { | ||
| 63 | try | ||
| 64 | { | ||
| 65 | if (File.Exists(path)) | ||
| 66 | { | ||
| 67 | File.Delete(path); | ||
| 68 | } | ||
| 69 | else if (Directory.Exists(path)) | ||
| 70 | { | ||
| 71 | Directory.Delete(path, true); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | catch | ||
| 75 | { | ||
| 76 | // Best effort delete, so ignore any failures. | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | this.Disposed = true; | ||
| 82 | } | ||
| 83 | |||
| 84 | #endregion | ||
| 85 | } | ||
| 86 | } | ||
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 @@ | |||
| 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 | |||
| 3 | namespace WixToolsetTest.CoreNative.Utility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | |||
| 8 | public class Pushd : IDisposable | ||
| 9 | { | ||
| 10 | protected bool Disposed { get; private set; } | ||
| 11 | |||
| 12 | public Pushd(string path) | ||
| 13 | { | ||
| 14 | this.PreviousDirectory = Directory.GetCurrentDirectory(); | ||
| 15 | |||
| 16 | Directory.SetCurrentDirectory(path); | ||
| 17 | } | ||
| 18 | |||
| 19 | public string PreviousDirectory { get; } | ||
| 20 | |||
| 21 | #region // IDisposable | ||
| 22 | |||
| 23 | public void Dispose() | ||
| 24 | { | ||
| 25 | this.Dispose(true); | ||
| 26 | GC.SuppressFinalize(this); | ||
| 27 | } | ||
| 28 | |||
| 29 | protected virtual void Dispose(bool disposing) | ||
| 30 | { | ||
| 31 | if (this.Disposed) | ||
| 32 | { | ||
| 33 | return; | ||
| 34 | } | ||
| 35 | |||
| 36 | if (disposing) | ||
| 37 | { | ||
| 38 | Directory.SetCurrentDirectory(this.PreviousDirectory); | ||
| 39 | } | ||
| 40 | |||
| 41 | this.Disposed = true; | ||
| 42 | } | ||
| 43 | |||
| 44 | #endregion | ||
| 45 | } | ||
| 46 | } | ||
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 @@ | |||
| 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 | |||
| 3 | namespace WixToolsetTest.CoreNative.Utility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | |||
| 8 | public class TestData | ||
| 9 | { | ||
| 10 | public static string LocalPath => Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); | ||
| 11 | |||
| 12 | public static string Get(params string[] paths) | ||
| 13 | { | ||
| 14 | return Path.Combine(LocalPath, Path.Combine(paths)); | ||
| 15 | } | ||
| 16 | } | ||
| 17 | } | ||
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 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 5 | <PropertyGroup> | ||
| 6 | <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| 7 | <IsPackable>false</IsPackable> | ||
| 8 | <RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
| 9 | </PropertyGroup> | ||
| 10 | |||
| 11 | <ItemGroup> | ||
| 12 | <Content Include="TestData\**" CopyToOutputDirectory="PreserveNewest" /> | ||
| 13 | </ItemGroup> | ||
| 14 | |||
| 15 | <ItemGroup> | ||
| 16 | <ProjectReference Include="..\..\WixToolset.Core.Native\WixToolset.Core.Native.csproj" /> | ||
| 17 | </ItemGroup> | ||
| 18 | |||
| 19 | <ItemGroup> | ||
| 20 | <PackageReference Include="GitInfo" Version="2.1.2" /> | ||
| 21 | |||
| 22 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" /> | ||
| 23 | <PackageReference Include="xunit" Version="2.4.1" /> | ||
| 24 | <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="All" /> | ||
| 25 | </ItemGroup> | ||
| 26 | </Project> | ||
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 @@ | |||
| 1 | v42.42.{height}-preview.0 \ No newline at end of file | ||
