From afbc6889c73d58136cb8851858ca3c17f41dc2c5 Mon Sep 17 00:00:00 2001
From: Sean Hall <r.sean.hall@gmail.com>
Date: Thu, 26 Mar 2020 15:21:06 +1000
Subject: Add BundleExtension element. Add GetTestXml. Fix issue with building
 with current version of burn.

---
 .../BundleManifestFixture.cs                       | 61 +++++++++++++++++++++
 .../TestData/BundleExtension/BundleExtension.wxs   |  6 +++
 .../BundleExtension/SimpleBundleExtension.wxs      | 10 ++++
 .../TestData/BundleWithPackageGroupRef/Bundle.wxs  |  9 ++++
 .../MinimalPackageGroup.wxs                        |  8 +++
 .../TestXmlFixture.cs                              | 62 ++++++++++++++++++++++
 .../WixToolsetTest.CoreIntegration.csproj          |  4 ++
 7 files changed, 160 insertions(+)
 create mode 100644 src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs
 create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/BundleExtension.wxs
 create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/SimpleBundleExtension.wxs
 create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs
 create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/MinimalPackageGroup.wxs
 create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestXmlFixture.cs

(limited to 'src/test')

diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs
new file mode 100644
index 00000000..da4482ff
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs
@@ -0,0 +1,61 @@
+// 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.Collections.Generic;
+    using System.IO;
+    using WixBuildTools.TestSupport;
+    using WixToolset.Core.TestPackage;
+    using Xunit;
+
+    public class BundleManifestFixture
+    {
+        [Fact]
+        public void PopulatesManifestWithBundleExtension()
+        {
+            var burnStubPath = TestData.Get(@"TestData\.Data\burn.exe");
+            var folder = TestData.Get(@"TestData");
+
+            using (var fs = new DisposableFileSystem())
+            {
+                var baseFolder = fs.GetFolder();
+                var intermediateFolder = Path.Combine(baseFolder, "obj");
+                var bundlePath = Path.Combine(baseFolder, @"bin\test.exe");
+                var baFolderPath = Path.Combine(baseFolder, "ba");
+                var extractFolderPath = Path.Combine(baseFolder, "extract");
+
+                var result = WixRunner.Execute(new[]
+                {
+                    "build",
+                    Path.Combine(folder, "BundleExtension", "BundleExtension.wxs"),
+                    Path.Combine(folder, "BundleExtension", "SimpleBundleExtension.wxs"),
+                    Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"),
+                    Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"),
+                    "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
+                    "-intermediateFolder", intermediateFolder,
+                    "-burnStub", burnStubPath,
+                    "-o", bundlePath
+                });
+
+                result.AssertSuccess();
+
+                Assert.True(File.Exists(bundlePath));
+
+                var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath);
+                extractResult.AssertSuccess();
+
+                var bundleExtensions = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:BundleExtension");
+                Assert.Equal(1, bundleExtensions.Count);
+                Assert.Equal("<BundleExtension Id='ExampleBext' EntryPayloadId='ExampleBext' />", bundleExtensions[0].GetTestXml());
+
+                var bundleExtensionPayloads = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:UX/burn:Payload[@Id='ExampleBext']");
+                Assert.Equal(1, bundleExtensionPayloads.Count);
+                var ignored = new Dictionary<string, List<string>>
+                {
+                    { "Payload", new List<string> { "FileSize", "Hash", "SourcePath" } },
+                };
+                Assert.Equal("<Payload Id='ExampleBext' FilePath='fakebext.dll' FileSize='*' Hash='*' Packaging='embedded' SourcePath='*' />", bundleExtensionPayloads[0].GetTestXml(ignored));
+            }
+        }
+    }
+}
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/BundleExtension.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/BundleExtension.wxs
new file mode 100644
index 00000000..eefae822
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/BundleExtension.wxs
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
+    <Fragment>
+        <BundleExtension Id="ExampleBext" SourceFile="fakeba.dll" Name="fakebext.dll" />
+    </Fragment>
+</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/SimpleBundleExtension.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/SimpleBundleExtension.wxs
new file mode 100644
index 00000000..7303a05a
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleExtension/SimpleBundleExtension.wxs
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
+    <Fragment>
+        <PackageGroup Id="BundlePackages">
+            <PackageGroupRef Id="MinimalPackageGroup" />
+        </PackageGroup>
+
+        <BundleExtensionRef Id="ExampleBext" />
+    </Fragment>
+</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs
new file mode 100644
index 00000000..207a8de1
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/Bundle.wxs
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
+    <Bundle Name="BurnBundle" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B94478B1-E1F3-4700-9CE8-6AA090854AEC">
+        <BootstrapperApplication SourceFile="fakeba.dll" />
+        <Chain>
+            <PackageGroupRef Id="BundlePackages" />
+        </Chain>
+    </Bundle>
+</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/MinimalPackageGroup.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/MinimalPackageGroup.wxs
new file mode 100644
index 00000000..b0bde4f6
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleWithPackageGroupRef/MinimalPackageGroup.wxs
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
+    <Fragment>
+        <PackageGroup Id="MinimalPackageGroup">
+            <MsiPackage SourceFile="test.msi" />
+        </PackageGroup>
+    </Fragment>
+</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestXmlFixture.cs b/src/test/WixToolsetTest.CoreIntegration/TestXmlFixture.cs
new file mode 100644
index 00000000..5330305e
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestXmlFixture.cs
@@ -0,0 +1,62 @@
+// 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.Collections.Generic;
+    using WixToolset.Core.TestPackage;
+    using Xunit;
+
+    public class TestXmlFixture
+    {
+        [Fact]
+        public void ChangesIgnoredAttributesToStarToHelpMakeTestsLessFragile()
+        {
+            var original = @"<Top One='f'>
+  <First Two='t'>
+    <Target One='a' Two='b' Three='c' />
+  </First>
+  <Target One='z' Two='x' Three = 'y' />
+</Top>";
+            var expected = "<Top One='f'><First Two='t'><Target One='*' Two='*' Three='c' /></First><Target One='*' Two='*' Three='y' /></Top>";
+            var ignored = new Dictionary<string, List<string>> { { "Target", new List<string> { "One", "Two", "Missing" } } };
+            Assert.Equal(expected, original.GetTestXml(ignored));
+        }
+
+        [Fact]
+        public void OutputsSingleQuotesSinceDoubleQuotesInCsharpLiteralStringsArePainful()
+        {
+            var original = "<Test Simple=\"\" EscapedDoubleQuote=\"&quot;\" SingleQuoteValue=\"'test'\" Alternating='\"' AlternatingEscaped='&quot;' />";
+            var expected = "<Test Simple='' EscapedDoubleQuote='\"' SingleQuoteValue='&apos;test&apos;' Alternating='\"' AlternatingEscaped='\"' />";
+            Assert.Equal(expected, original.GetTestXml());
+        }
+
+        [Fact]
+        public void RemovesAllNamespacesToReduceTyping()
+        {
+            var original = "<Test xmlns='a'><Child xmlns:b='b'><Grandchild xmlns:c='c' /><Grandchild /></Child></Test>";
+            var expected = "<Test><Child><Grandchild /><Grandchild /></Child></Test>";
+            Assert.Equal(expected, original.GetTestXml());
+        }
+
+        [Fact]
+        public void RemovesUnnecessaryWhitespaceToAvoidLineEndingIssues()
+        {
+            var original = @"<Test>
+  <Child>
+    <Grandchild />
+    <Grandchild />
+  </Child>
+</Test>";
+            var expected = "<Test><Child><Grandchild /><Grandchild /></Child></Test>";
+            Assert.Equal(expected, original.GetTestXml());
+        }
+
+        [Fact]
+        public void RemovesXmlDeclarationToReduceTyping()
+        {
+            var original = "<?xml version='1.0'?><Test />";
+            var expected = "<Test />";
+            Assert.Equal(expected, original.GetTestXml());
+        }
+    }
+}
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
index 7f21fde1..85538b79 100644
--- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
@@ -21,6 +21,10 @@
     <Content Include="TestData\AppSearch\FileSearch.wxs" CopyToOutputDirectory="PreserveNewest" />
     <Content Include="TestData\AppSearch\NestedDirSearchUnderRegSearch.msi" CopyToOutputDirectory="PreserveNewest" />
     <Content Include="TestData\AppSearch\RegistrySearch.wxs" CopyToOutputDirectory="PreserveNewest" />
+    <Content Include="TestData\BundleExtension\BundleExtension.wxs" CopyToOutputDirectory="PreserveNewest" />
+    <Content Include="TestData\BundleExtension\SimpleBundleExtension.wxs" CopyToOutputDirectory="PreserveNewest" />
+    <Content Include="TestData\BundleWithPackageGroupRef\Bundle.wxs" CopyToOutputDirectory="PreserveNewest" />
+    <Content Include="TestData\BundleWithPackageGroupRef\MinimalPackageGroup.wxs" CopyToOutputDirectory="PreserveNewest" />
     <Content Include="TestData\Class\DecompiledOldClassTableDef.wxs" CopyToOutputDirectory="PreserveNewest" />
     <Content Include="TestData\Class\IconIndex0.wxs" CopyToOutputDirectory="PreserveNewest" />
     <Content Include="TestData\Class\OldClassTableDef.msi" CopyToOutputDirectory="PreserveNewest" />
-- 
cgit v1.2.3-55-g6feb