From 720c4a0db1a2fb2aa3e08e5c99d5198873e448ba Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 1 Dec 2017 01:09:42 -0800 Subject: Introduce ExampleExtension for testing --- .../ExtensionFixture.cs | 60 ++++++++++++++++++++++ .../TestData/ExampleExtension/Package.en-us.wxl | 11 ++++ .../TestData/ExampleExtension/Package.wxs | 21 ++++++++ .../ExampleExtension/PackageComponents.wxs | 12 +++++ .../TestData/ExampleExtension/data/example.txt | 1 + .../WixToolsetTest.CoreIntegration.csproj | 5 ++ 6 files changed, 110 insertions(+) create mode 100644 src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/data/example.txt (limited to 'src/test/WixToolsetTest.CoreIntegration') diff --git a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs new file mode 100644 index 00000000..5181c748 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs @@ -0,0 +1,60 @@ +// 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; + using System.IO; + using System.Linq; + using Example.Extension; + using WixToolset.Core; + using WixToolset.Data; + using WixToolset.Data.Tuples; + using WixToolsetTest.CoreIntegration.Utility; + using Xunit; + + public class ExtensionFixture + { + [Fact] + public void CanBuildWithExampleExtension() + { + var folder = TestData.Get(@"TestData\ExampleExtension"); + var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); + + using (var fs = new DisposableFileSystem()) + { + var intermediateFolder = fs.GetFolder(); + + var program = new Program(); + var result = program.Run(new WixToolsetServiceProvider(), new[] + { + "build", + Path.Combine(folder, "Package.wxs"), + Path.Combine(folder, "PackageComponents.wxs"), + "-loc", Path.Combine(folder, "Package.en-us.wxl"), + "-ext", extensionPath, + "-bindpath", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(intermediateFolder, @"bin\extest.msi") + }); + + 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")); + Assert.Single(intermediate.Sections); + + var wixFile = intermediate.Sections.SelectMany(s => s.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 example = intermediate.Sections.SelectMany(s => s.Tuples).Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).Single(); + Assert.Equal("Foo", example.Id.Id); + Assert.Equal("Foo", example[0].AsString()); + Assert.Equal("Bar", example[1].AsString()); + } + } + } +} diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/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/ExampleExtension/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.wxs new file mode 100644 index 00000000..cdc323ec --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.wxs @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/PackageComponents.wxs new file mode 100644 index 00000000..7f17b538 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/PackageComponents.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/data/example.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/data/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/data/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index f9042cda..ede5967f 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -15,6 +15,10 @@ + + + + @@ -23,6 +27,7 @@ + -- cgit v1.2.3-55-g6feb