From be163ecb92398a8d569a7e97aaf25bc7e5fb9eec Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 29 Dec 2017 03:57:03 -0800 Subject: Move to WixBuildTools.TestSupport --- .../ExtensionFixture.cs | 30 +++++--- .../ProgramFixture.cs | 8 +- .../Utility/DisposableFileSystem.cs | 86 ---------------------- .../Utility/Pushd.cs | 46 ------------ .../Utility/TestData.cs | 17 ----- .../WixToolsetTest.CoreIntegration.csproj | 8 ++ 6 files changed, 33 insertions(+), 162 deletions(-) delete mode 100644 src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs delete mode 100644 src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs delete mode 100644 src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs (limited to 'src/test/WixToolsetTest.CoreIntegration') diff --git a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs index 3714f9e7..5de61368 100644 --- a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs @@ -6,14 +6,27 @@ namespace WixToolsetTest.CoreIntegration using System.IO; using System.Linq; using Example.Extension; + using WixBuildTools.TestSupport; using WixToolset.Core; using WixToolset.Data; using WixToolset.Data.Tuples; - using WixToolsetTest.CoreIntegration.Utility; using Xunit; public class ExtensionFixture { + [Fact] + public void CanBuildAndQuery() + { + var folder = TestData.Get(@"TestData\ExampleExtension"); + var build = new Builder(folder, typeof(ExampleExtensionFactory), new[] { Path.Combine(folder, "data") }); + + var results = build.BuildAndQuery(Build, "Example"); + Assert.Equal(new[] + { + "Example:Foo\tBar" + }, results); + } + [Fact] public void CanBuildWithExampleExtension() { @@ -83,21 +96,20 @@ namespace WixToolsetTest.CoreIntegration Assert.Equal(0, result); - Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\extest.msi"))); - Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\extest.wixpdb"))); - Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\MsiPackage\example.txt"))); - var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\extest.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\example.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"example.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); - var property = section.Tuples.OfType().Where(p => p.Id.Id == "ExampleProperty").Single(); Assert.Equal("ExampleProperty", property.Property); Assert.Equal("test", property.Value); } } + + private static void Build(string[] args) + { + var program = new Program(); + var result = program.Run(new WixToolsetServiceProvider(), null, args); + Assert.Equal(0, result); + } } } diff --git a/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs index b4a7c8b2..7e54174d 100644 --- a/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs @@ -4,11 +4,11 @@ namespace WixToolsetTest.CoreIntegration { using System.IO; using System.Linq; + using WixBuildTools.TestSupport; using WixToolset.Core; using WixToolset.Data; using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; - using WixToolsetTest.CoreIntegration.Utility; using Xunit; public class ProgramFixture @@ -247,7 +247,7 @@ namespace WixToolsetTest.CoreIntegration } [Fact] - public void CanBuildWixout() + public void CanBuildWixipl() { var folder = TestData.Get(@"TestData\SingleFile"); @@ -265,7 +265,7 @@ namespace WixToolsetTest.CoreIntegration "-loc", Path.Combine(folder, "Package.en-us.wxl"), "-bindpath", Path.Combine(folder, "data"), "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(baseFolder, @"bin\test.wixout") + "-o", Path.Combine(baseFolder, @"bin\test.wixipl") }); Assert.Equal(0, result); @@ -273,7 +273,7 @@ namespace WixToolsetTest.CoreIntegration var builtFiles = Directory.GetFiles(Path.Combine(baseFolder, @"bin")); Assert.Equal(new[]{ - "test.wixout" + "test.wixipl" }, builtFiles.Select(Path.GetFileName).ToArray()); } } diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs deleted file mode 100644 index 795d344a..00000000 --- a/src/test/WixToolsetTest.CoreIntegration/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.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 deleted file mode 100644 index efd733a7..00000000 --- a/src/test/WixToolsetTest.CoreIntegration/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.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 deleted file mode 100644 index e3b21183..00000000 --- a/src/test/WixToolsetTest.CoreIntegration/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.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 index e4c2713c..d406a0da 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -7,6 +7,10 @@ false + + NU1701 + + @@ -42,6 +46,10 @@ + + + + -- cgit v1.2.3-55-g6feb