Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for unit testing multiple extensions #434

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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