Skip to content

Commit

Permalink
Add unit test for WixStdba payload
Browse files Browse the repository at this point in the history
  • Loading branch information
drolevar committed Aug 1, 2024
1 parent f577d4c commit 956b6f5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace WixToolsetTest.BootstrapperApplications
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using WixToolset.BootstrapperApplications;
using WixInternal.Core.TestPackage;
using WixInternal.TestSupport;
using WixToolset.Core;
using WixToolset.Extensibility.Data;
using WixToolset.Extensibility.Services;
using Xunit;

public class BalExtensionFixture
Expand Down Expand Up @@ -51,6 +53,52 @@ public void CanBuildUsingDisplayInternalUICondition()
}
}

[Fact]
public void CanBuildUsingBootstrapperApplicationId()
{
using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var bundleFile = Path.Combine(baseFolder, "bin", "test.exe");
var bundleSourceFolder = TestData.Get(@"TestData\WixStdBa");
var intermediateFolder = Path.Combine(baseFolder, "obj");
var baFolderPath = Path.Combine(baseFolder, "ba");
var extractFolderPath = Path.Combine(baseFolder, "extract");

var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
var parseHelper = serviceProvider.GetService<IParseHelper>();
var compileContext = serviceProvider.GetService<ICompileContext>();
var wixStdBaId = parseHelper.CreateIdentifierValueFromPlatform( "WixStandardBootstrapperApplication", compileContext.Platform, BurnPlatforms.X86 | BurnPlatforms.X64 | BurnPlatforms.ARM64);

var compileResult = WixRunner.Execute(new[]
{
"build",
Path.Combine(bundleSourceFolder, "BootstrapperApplicationId.wxs"),
"-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"),
"-intermediateFolder", intermediateFolder,
"-bindpath", Path.Combine(bundleSourceFolder, "data"),
"-o", bundleFile,
});
compileResult.AssertSuccess();

Assert.True(File.Exists(bundleFile));

var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath);
extractResult.AssertSuccess();

var ignoreAttributesByElementName = new Dictionary<string, List<string>>
{
{ "Payload", new List<string> { "SourcePath" } },
};

var wixStdBaPayloadInfo = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:UX/burn:Payload[@FilePath='wixstdba.exe']", ignoreAttributesByElementName);
WixAssert.CompareLineByLine(new string[]
{
$@"<Payload Id='{wixStdBaId}' FilePath='wixstdba.exe' SourcePath='*' />"
}, wixStdBaPayloadInfo);
}
}

[Fact]
public void CanBuildUsingOverridable()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
<Bundle Name="WixStdBa" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="75D5D534-E177-4689-AAE9-CAC1C39002C2">
<BootstrapperApplication Id="Custom">
<bal:WixStandardBootstrapperApplication LicenseUrl="http://wixtoolset.org/about/license/" Theme="hyperlinkLicense" />
</BootstrapperApplication>
<Chain>
<MsiPackage SourceFile="test.msi" />
</Chain>
</Bundle>
</Wix>

0 comments on commit 956b6f5

Please sign in to comment.