1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
// 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.BurnE2E
{
using System;
using System.IO;
using WixTestTools;
using Xunit;
using Xunit.Abstractions;
public class PrereqBaTests : BurnE2ETests
{
public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
/// <summary>
/// This bundle purposely misnames its .runtimeconfig.json file to force the PreqBA to kick in
/// and use its EXE prereq package to swap in a good one.
/// This verifies that:
/// The mangaged BA fails to load due to the missing file.
/// The preqba kicks in to copy in the file.
/// The managed BA gets loaded.
/// </summary>
[RuntimeFact]
public void DncLoadsOnlyAfterInstallingPrereqs()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleA = this.CreateBundleInstaller("BundleA");
var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleA.Install();
// Source file should be installed
Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleA.VerifyRegisteredAndInPackageCache();
bundleA.Uninstall();
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// <summary>
/// This bundle purposely misnames its .runtimeconfig.json file to force the PreqBA to kick in
/// and use its EXE prereq package to swap in a good one.
/// This verifies that:
/// The preqba runs first to fix the file.
/// The managed BA gets loaded on first try.
/// </summary>
[RuntimeFact]
public void DncPreqsFirstThenBaLoadsManagedBa()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleC = this.CreateBundleInstaller("BundleC");
var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleC.Install();
// Source file should be installed
Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleC.VerifyRegisteredAndInPackageCache();
bundleC.Uninstall();
bundleC.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// This bundle purposely misnames its WixToolset.Mba.Host.config file to force the PreqBA to kick in
/// and use its EXE prereq package to swap in a good one.
/// This verifies that:
/// The mangaged BA fails to load due to the missing file.
/// The preqba kicks in to copy in the file.
/// The managed BA gets loaded.
/// </summary>
[RuntimeFact(Skip = "It is no longer possible to replace the bad.config with a good config, these tests do not work for .NET Framework the way they can for .NET above.")]
public void MbaLoadsOnlyAfterInstallingPrereqs()
{
var packageB = this.CreatePackageInstaller("PackageB");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleB = this.CreateBundleInstaller("BundleB");
var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleB.Install();
// Source file should be installed
Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleB.VerifyRegisteredAndInPackageCache();
bundleB.Uninstall();
// No non-permanent packages should have ended up installed or cached so it should have unregistered.
bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// This bundle purposely misnames its WixToolset.Mba.Host.config file to force the PreqBA to kick in
/// and use its EXE prereq package to swap in a good one.
/// This verifies that:
/// The preqba runs first to fix the file.
/// The managed BA gets loaded on first try.
/// </summary>
[RuntimeFact(Skip = "It is no longer possible to replace the bad.config with a good config, these tests do not work for .NET Framework the way they can for .NET above.")]
public void MbaPreqsFirstThenBaLoadsManagedBa()
{
var packageB = this.CreatePackageInstaller("PackageB");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleD = this.CreateBundleInstaller("BundleD");
var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleD.Install();
// Source file should be installed
Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleD.VerifyRegisteredAndInPackageCache();
bundleD.Uninstall();
bundleD.VerifyUnregisteredAndRemovedFromPackageCache();
}
[RuntimeFact]
public void DncAlwaysPreqBaForwardsHelpToManagedBa()
{
var bundleE = this.CreateBundleInstaller("BundleE");
var bundleLog = bundleE.Help();
Assert.True(LogVerifier.MessageInLogFile(bundleLog, "This is a BA for automated testing"));
}
}
}
|