Skip to content

Commit

Permalink
Multiple extension support in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbednarski committed Jul 22, 2023
1 parent e0641f1 commit 6c66dd3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
35 changes: 25 additions & 10 deletions src/internal/WixInternal.TestSupport/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,29 @@ public class Builder
public Builder(string sourceFolder, Type extensionType = null, string[] bindPaths = null, string outputFile = null)
{
this.SourceFolder = sourceFolder;
this.ExtensionType = extensionType;
if (extensionType != null)
{
this.ExtensionTypes = new Type[] { extensionType };
}
else
{
this.ExtensionTypes = new Type[] { };
}
this.BindPaths = bindPaths;
this.OutputFile = outputFile ?? "test.msi";
}

public Builder(string sourceFolder, Type[] extensionTypes, string[] bindPaths = null, string outputFile = null)
{
this.SourceFolder = sourceFolder;
this.ExtensionTypes = extensionTypes;
this.BindPaths = bindPaths;
this.OutputFile = outputFile ?? "test.msi";
}

public string[] BindPaths { get; set; }

public Type ExtensionType { get; set; }
public Type[] ExtensionTypes { get; set; }

public string OutputFile { get; set; }

Expand Down Expand Up @@ -46,10 +61,10 @@ public string[] BuildAndQuery(Action<string[]> buildFunc, bool validate, params
"-intermediateFolder", intermediateFolder,
};

if (this.ExtensionType != null)
foreach (var ext in this.ExtensionTypes)
{
args.Add("-ext");
args.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
args.Add(Path.GetFullPath(new Uri(ext.Assembly.CodeBase).LocalPath));
}

args.AddRange(sourceFiles);
Expand Down Expand Up @@ -108,10 +123,10 @@ public void BuildAndDecompileAndBuild(Action<string[]> buildFunc, Action<string[
"-intermediateFolder", intermediateFolder,
};

if (this.ExtensionType != null)
foreach (var ext in this.ExtensionTypes)
{
firstBuildArgs.Add("-ext");
firstBuildArgs.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
firstBuildArgs.Add(Path.GetFullPath(new Uri(ext.Assembly.CodeBase).LocalPath));
}

firstBuildArgs.AddRange(sourceFiles);
Expand Down Expand Up @@ -140,10 +155,10 @@ public void BuildAndDecompileAndBuild(Action<string[]> buildFunc, Action<string[
"-o", decompilePath
};

if (this.ExtensionType != null)
foreach (var ext in this.ExtensionTypes)
{
decompileArgs.Add("-ext");
decompileArgs.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
decompileArgs.Add(Path.GetFullPath(new Uri(ext.Assembly.CodeBase).LocalPath));
}

decompileFunc(decompileArgs.ToArray());
Expand All @@ -157,10 +172,10 @@ public void BuildAndDecompileAndBuild(Action<string[]> buildFunc, Action<string[
"-intermediateFolder", decompileIntermediateFolder
};

if (this.ExtensionType != null)
foreach (var ext in this.ExtensionTypes)
{
secondBuildArgs.Add("-ext");
secondBuildArgs.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
secondBuildArgs.Add(Path.GetFullPath(new Uri(ext.Assembly.CodeBase).LocalPath));
}

secondBuildArgs.Add("-bindpath");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WixToolsetTest.CoreIntegration
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -152,7 +153,7 @@ public void CanBuildBundleWithCustomProviderKey()
public void CanBuildPackageUsingProvides()
{
var folder = TestData.Get(@"TestData\UsingProvides");
var build = new Builder(folder, null, new[] { folder });
var build = new Builder(folder, new Type[] { }, new[] { folder });

var results = build.BuildAndQuery(Build, "Wix4DependencyProvider");
WixAssert.CompareLineByLine(new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WixToolsetTest.CoreIntegration
{
using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
Expand All @@ -19,7 +20,7 @@ public class SoftwareTagFixture
public void CanBuildPackageWithTag()
{
var folder = TestData.Get(@"TestData\ProductTag");
var build = new Builder(folder, null, new[] { folder });
var build = new Builder(folder, new Type[] { }, new[] { folder });

var results = build.BuildAndQuery(Build, "File", "SoftwareIdentificationTag");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WixToolsetTest.CoreIntegration
{
using System;
using System.IO;
using System.Linq;
using WixInternal.TestSupport;
Expand Down Expand Up @@ -45,7 +46,7 @@ public void FailsOnInvalidVersion()
public void MajorUpgradeDowngradeMessagePopulatesRowsAsExpected()
{
var folder = TestData.Get("TestData", "Upgrade");
var build = new Builder(folder, null, new[] { folder });
var build = new Builder(folder, new Type[] { }, new[] { folder });

var results = build.BuildAndQuery(Build, "Upgrade", "LaunchCondition");
WixAssert.CompareLineByLine(new[]
Expand Down

0 comments on commit 6c66dd3

Please sign in to comment.