From b387913d0e76aa7863f8766868cd2fb3b3fffcde Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 29 Nov 2017 22:11:32 -0800 Subject: Remove "Fixture" from the test assembly name --- .../ProgramFixture.cs | 90 ++++++++++++++++++++++ .../TestData/InstanceTransform/Package.en-us.wxl | 11 +++ .../TestData/InstanceTransform/Package.wxs | 27 +++++++ .../InstanceTransform/PackageComponents.wxs | 10 +++ .../TestData/InstanceTransform/data/test.txt | 1 + .../TestData/SimpleModule/Module.en-us.wxl | 10 +++ .../TestData/SimpleModule/Module.wixproj | 48 ++++++++++++ .../TestData/SimpleModule/Module.wxs | 16 ++++ .../TestData/SimpleModule/data/test.txt | 1 + .../TestData/SingleFile/Package.en-us.wxl | 11 +++ .../TestData/SingleFile/Package.wxs | 21 +++++ .../TestData/SingleFile/PackageComponents.wxs | 10 +++ .../TestData/SingleFile/data/test.txt | 1 + .../Utility/DisposableFileSystem.cs | 86 +++++++++++++++++++++ .../Utility/Pushd.cs | 46 +++++++++++ .../Utility/TestData.cs | 17 ++++ .../WixToolsetTest.CoreIntegration.csproj | 33 ++++++++ 17 files changed, 439 insertions(+) create mode 100644 src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/data/test.txt create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/data/test.txt create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/data/test.txt create mode 100644 src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs create mode 100644 src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs create mode 100644 src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs create mode 100644 src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj (limited to 'src/test/WixToolsetTest.CoreIntegration') diff --git a/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs new file mode 100644 index 00000000..9859c05a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs @@ -0,0 +1,90 @@ +// 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.CoreIntegration +{ + using System.IO; + using System.Linq; + using WixToolset.Core; + using WixToolset.Data; + using WixToolset.Data.Tuples; + using WixToolsetTest.CoreIntegration.Utility; + using Xunit; + + public class ProgramFixture + { + [Fact] + public void CanBuildSingleFile() + { + var folder = TestData.Get(@"TestData\SingleFile"); + + using (var fs = new DisposableFileSystem()) + using (var pushd = new Pushd(folder)) + { + var intermediateFolder = fs.GetFolder(); + + var program = new Program(); + var result = program.Run(new WixToolsetServiceProvider(), new[] { "build", "Package.wxs", "PackageComponents.wxs", "-loc", "Package.en-us.wxl", "-bindpath", "data", "-intermediateFolder", intermediateFolder, "-o", $@"{intermediateFolder}\bin\test.msi" }); + + Assert.Equal(0, result); + + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi"))); + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\MsiPackage\test.txt"))); + + var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wir")); + Assert.Single(intermediate.Sections); + + var wixFile = intermediate.Sections.SelectMany(s => s.Tuples).OfType().Single(); + Assert.Equal(@"data\test.txt", wixFile[WixFileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + } + } + + [Fact] + public void CanBuildSimpleModule() + { + var folder = TestData.Get(@"TestData\SimpleModule"); + + using (var fs = new DisposableFileSystem()) + using (var pushd = new Pushd(folder)) + { + var intermediateFolder = fs.GetFolder(); + + var program = new Program(); + var result = program.Run(new WixToolsetServiceProvider(), new[] { "build", "Module.wxs", "-loc", "Module.en-us.wxl", "-bindpath", "data", "-intermediateFolder", intermediateFolder, "-o", $@"{intermediateFolder}\bin\test.msm" }); + + Assert.Equal(0, result); + + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msm"))); + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); + + var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wir")); + Assert.Single(intermediate.Sections); + + var wixFile = intermediate.Sections.SelectMany(s => s.Tuples).OfType().Single(); + Assert.Equal(@"data\test.txt", wixFile[WixFileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + } + } + + [Fact(Skip = "Not implemented yet.")] + public void CanBuildInstanceTransform() + { + var folder = TestData.Get(@"TestData\InstanceTransform"); + + using (var fs = new DisposableFileSystem()) + using (var pushd = new Pushd(folder)) + { + var intermediateFolder = fs.GetFolder(); + + var program = new Program(); + var result = program.Run(new WixToolsetServiceProvider(), new[] { "build", "Package.wxs", "PackageComponents.wxs", "-loc", "Package.en-us.wxl", "-bindpath", "data", "-intermediateFolder", intermediateFolder, "-o", $@"{intermediateFolder}\bin\test.msi" }); + + Assert.Equal(0, result); + + var pdb = Pdb.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"), false); + Assert.NotEmpty(pdb.Output.SubStorages); + } + } + } +} diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs new file mode 100644 index 00000000..9c529668 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/PackageComponents.wxs new file mode 100644 index 00000000..e26c4509 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/PackageComponents.wxs @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.en-us.wxl new file mode 100644 index 00000000..c74e86a7 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.en-us.wxl @@ -0,0 +1,10 @@ + + + + + + Example Company + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj new file mode 100644 index 00000000..597d4318 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj @@ -0,0 +1,48 @@ + + + + Debug + x86 + 0.9 + 27df04c6-3cef-4b9a-bac6-4e78d188384f + MergeModule1 + Module + MergeModule1 + MergeModule1 + + + $(Platform) + bin\$(Platform)\$(Configuration)\ + Debug + + + $(Platform) + bin\$(Platform)\$(Configuration)\ + + + $(Platform) + bin\$(Platform)\$(Configuration)\ + Debug + + + $(Platform) + bin\$(Platform)\$(Configuration)\ + + + + + + + + + + FgwepExtension.wixext + $(WixExtDir)\FgwepExtension.wixext.dll + + + + + + + + \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs new file mode 100644 index 00000000..260339ba --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs new file mode 100644 index 00000000..cdc323ec --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/PackageComponents.wxs new file mode 100644 index 00000000..e26c4509 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/PackageComponents.wxs @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs new file mode 100644 index 00000000..795d344a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs @@ -0,0 +1,86 @@ +// 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.CoreIntegration.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(); + + protected 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.CoreIntegration/Utility/Pushd.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs new file mode 100644 index 00000000..efd733a7 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs @@ -0,0 +1,46 @@ +// 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.CoreIntegration.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.CoreIntegration/Utility/TestData.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs new file mode 100644 index 00000000..e3b21183 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs @@ -0,0 +1,17 @@ +// 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.CoreIntegration.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.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj new file mode 100644 index 00000000..f9042cda --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -0,0 +1,33 @@ + + + + + + netcoreapp2.0 + false + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb