aboutsummaryrefslogtreecommitdiff
path: root/src/WixTestTools
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixTestTools')
-rw-r--r--src/WixTestTools/BundleRegistration.cs5
-rw-r--r--src/WixTestTools/BundleVerifier.cs11
-rw-r--r--src/WixTestTools/PackageInstaller.cs14
-rw-r--r--src/WixTestTools/PackageVerifier.cs30
-rw-r--r--src/WixTestTools/WixTestContext.cs10
5 files changed, 38 insertions, 32 deletions
diff --git a/src/WixTestTools/BundleRegistration.cs b/src/WixTestTools/BundleRegistration.cs
index bf9e2903..75660838 100644
--- a/src/WixTestTools/BundleRegistration.cs
+++ b/src/WixTestTools/BundleRegistration.cs
@@ -88,9 +88,10 @@ namespace WixTestTools
88 88
89 public string Version { get; set; } 89 public string Version { get; set; }
90 90
91 public static bool TryGetPerMachineBundleRegistrationById(string bundleId, out BundleRegistration registration) 91 public static bool TryGetPerMachineBundleRegistrationById(string bundleId, bool x64, out BundleRegistration registration)
92 { 92 {
93 var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY_WOW6432NODE}\\{bundleId}"; 93 var baseKeyPath = x64 ? BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY : BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY_WOW6432NODE;
94 var registrationKeyPath = $"{baseKeyPath}\\{bundleId}";
94 using var registrationKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); 95 using var registrationKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath);
95 var success = registrationKey != null; 96 var success = registrationKey != null;
96 registration = success ? GetBundleRegistration(registrationKey) : null; 97 registration = success ? GetBundleRegistration(registrationKey) : null;
diff --git a/src/WixTestTools/BundleVerifier.cs b/src/WixTestTools/BundleVerifier.cs
index 293da560..984df169 100644
--- a/src/WixTestTools/BundleVerifier.cs
+++ b/src/WixTestTools/BundleVerifier.cs
@@ -73,10 +73,11 @@ namespace WixTestTools
73 public bool TryGetRegistration(out BundleRegistration registration) 73 public bool TryGetRegistration(out BundleRegistration registration)
74 { 74 {
75 var bundleSymbol = this.GetBundleSymbol(); 75 var bundleSymbol = this.GetBundleSymbol();
76 var x64 = bundleSymbol.Platform != Platform.X86;
76 var bundleId = bundleSymbol.BundleId; 77 var bundleId = bundleSymbol.BundleId;
77 if (bundleSymbol.PerMachine) 78 if (bundleSymbol.PerMachine)
78 { 79 {
79 return BundleRegistration.TryGetPerMachineBundleRegistrationById(bundleId, out registration); 80 return BundleRegistration.TryGetPerMachineBundleRegistrationById(bundleId, x64, out registration);
80 } 81 }
81 else 82 else
82 { 83 {
@@ -132,9 +133,9 @@ namespace WixTestTools
132 Assert.True(Directory.Exists(cachePath)); 133 Assert.True(Directory.Exists(cachePath));
133 } 134 }
134 135
135 public void VerifyExeTestRegistryRootDeleted(string name) 136 public void VerifyExeTestRegistryRootDeleted(string name, bool x64 = false)
136 { 137 {
137 using var testRegistryRoot = this.TestContext.GetTestRegistryRoot(name); 138 using var testRegistryRoot = this.TestContext.GetTestRegistryRoot(x64, name);
138 if (testRegistryRoot != null) 139 if (testRegistryRoot != null)
139 { 140 {
140 var actualValue = testRegistryRoot.GetValue("Version") as string; 141 var actualValue = testRegistryRoot.GetValue("Version") as string;
@@ -142,9 +143,9 @@ namespace WixTestTools
142 } 143 }
143 } 144 }
144 145
145 public void VerifyExeTestRegistryValue(string name, string expectedValue) 146 public void VerifyExeTestRegistryValue(string name, string expectedValue, bool x64 = false)
146 { 147 {
147 using (var root = this.TestContext.GetTestRegistryRoot(name)) 148 using (var root = this.TestContext.GetTestRegistryRoot(x64, name))
148 { 149 {
149 Assert.NotNull(root); 150 Assert.NotNull(root);
150 var actualValue = root.GetValue("Version") as string; 151 var actualValue = root.GetValue("Version") as string;
diff --git a/src/WixTestTools/PackageInstaller.cs b/src/WixTestTools/PackageInstaller.cs
index 86376b9f..d32f499b 100644
--- a/src/WixTestTools/PackageInstaller.cs
+++ b/src/WixTestTools/PackageInstaller.cs
@@ -4,6 +4,10 @@ namespace WixTestTools
4{ 4{
5 using System; 5 using System;
6 using System.IO; 6 using System.IO;
7 using System.Linq;
8 using WixToolset.Data;
9 using WixToolset.Data.Symbols;
10 using WixToolset.Data.WindowsInstaller;
7 using static WixTestTools.MSIExec; 11 using static WixTestTools.MSIExec;
8 12
9 public partial class PackageInstaller : IDisposable 13 public partial class PackageInstaller : IDisposable
@@ -13,6 +17,16 @@ namespace WixTestTools
13 this.Package = Path.Combine(testContext.TestDataFolder, $"{filename}.msi"); 17 this.Package = Path.Combine(testContext.TestDataFolder, $"{filename}.msi");
14 this.PackagePdb = Path.Combine(testContext.TestDataFolder, $"{filename}.wixpdb"); 18 this.PackagePdb = Path.Combine(testContext.TestDataFolder, $"{filename}.wixpdb");
15 this.TestContext = testContext; 19 this.TestContext = testContext;
20
21 using var wixOutput = WixOutput.Read(this.PackagePdb);
22
23 var intermediate = Intermediate.Load(wixOutput);
24 var section = intermediate.Sections.Single();
25 var platformSummary = section.Symbols.OfType<SummaryInformationSymbol>().Single(s => s.PropertyId == SummaryInformationType.PlatformAndLanguage);
26 var platformString = platformSummary.Value.Split(new char[] { ';' }, 2)[0];
27 this.IsX64 = platformString != "Intel";
28
29 this.WiData = WindowsInstallerData.Load(wixOutput);
16 } 30 }
17 31
18 public string Package { get; } 32 public string Package { get; }
diff --git a/src/WixTestTools/PackageVerifier.cs b/src/WixTestTools/PackageVerifier.cs
index 073e83b0..2f42dd21 100644
--- a/src/WixTestTools/PackageVerifier.cs
+++ b/src/WixTestTools/PackageVerifier.cs
@@ -5,7 +5,6 @@ namespace WixTestTools
5 using System; 5 using System;
6 using System.IO; 6 using System.IO;
7 using System.Linq; 7 using System.Linq;
8 using WixToolset.Data;
9 using WixToolset.Data.WindowsInstaller; 8 using WixToolset.Data.WindowsInstaller;
10 using WixToolset.Data.WindowsInstaller.Rows; 9 using WixToolset.Data.WindowsInstaller.Rows;
11 using Xunit; 10 using Xunit;
@@ -14,28 +13,18 @@ namespace WixTestTools
14 { 13 {
15 public string PackagePdb { get; } 14 public string PackagePdb { get; }
16 15
17 private WindowsInstallerData WiData { get; set; } 16 private bool IsX64 { get; }
18 17
19 public string GetInstalledFilePath(string filename) 18 private WindowsInstallerData WiData { get; }
20 {
21 return this.TestContext.GetTestInstallFolder(Path.Combine(this.GetInstallFolderName(), filename));
22 }
23 19
24 private WindowsInstallerData GetWindowsInstallerData() 20 public string GetInstalledFilePath(string filename)
25 { 21 {
26 if (this.WiData == null) 22 return this.TestContext.GetTestInstallFolder(this.IsX64, Path.Combine(this.GetInstallFolderName(), filename));
27 {
28 using var wixOutput = WixOutput.Read(this.PackagePdb);
29 this.WiData = WindowsInstallerData.Load(wixOutput);
30 }
31
32 return this.WiData;
33 } 23 }
34 24
35 public string GetInstallFolderName() 25 public string GetInstallFolderName()
36 { 26 {
37 var wiData = this.GetWindowsInstallerData(); 27 var row = this.WiData.Tables["Directory"].Rows.Single(r => r.FieldAsString(0) == "INSTALLFOLDER");
38 var row = wiData.Tables["Directory"].Rows.Single(r => r.FieldAsString(0) == "INSTALLFOLDER");
39 var value = row.FieldAsString(2); 28 var value = row.FieldAsString(2);
40 var longNameIndex = value.IndexOf('|') + 1; 29 var longNameIndex = value.IndexOf('|') + 1;
41 if (longNameIndex > 0) 30 if (longNameIndex > 0)
@@ -47,8 +36,7 @@ namespace WixTestTools
47 36
48 public string GetProperty(string name) 37 public string GetProperty(string name)
49 { 38 {
50 var wiData = this.GetWindowsInstallerData(); 39 var row = this.WiData.Tables["Property"].Rows.Cast<PropertyRow>().Single(r => r.Property == name);
51 var row = wiData.Tables["Property"].Rows.Cast<PropertyRow>().Single(r => r.Property == name);
52 return row.Value; 40 return row.Value;
53 } 41 }
54 42
@@ -67,7 +55,7 @@ namespace WixTestTools
67 55
68 public void DeleteTestRegistryValue(string name) 56 public void DeleteTestRegistryValue(string name)
69 { 57 {
70 using (var root = this.TestContext.GetTestRegistryRoot()) 58 using (var root = this.TestContext.GetTestRegistryRoot(this.IsX64))
71 { 59 {
72 Assert.NotNull(root); 60 Assert.NotNull(root);
73 root.DeleteValue(name); 61 root.DeleteValue(name);
@@ -76,13 +64,13 @@ namespace WixTestTools
76 64
77 public void VerifyTestRegistryRootDeleted() 65 public void VerifyTestRegistryRootDeleted()
78 { 66 {
79 using var testRegistryRoot = this.TestContext.GetTestRegistryRoot(); 67 using var testRegistryRoot = this.TestContext.GetTestRegistryRoot(this.IsX64);
80 Assert.Null(testRegistryRoot); 68 Assert.Null(testRegistryRoot);
81 } 69 }
82 70
83 public void VerifyTestRegistryValue(string name, string expectedValue) 71 public void VerifyTestRegistryValue(string name, string expectedValue)
84 { 72 {
85 using (var root = this.TestContext.GetTestRegistryRoot()) 73 using (var root = this.TestContext.GetTestRegistryRoot(this.IsX64))
86 { 74 {
87 Assert.NotNull(root); 75 Assert.NotNull(root);
88 var actualValue = root.GetValue(name) as string; 76 var actualValue = root.GetValue(name) as string;
diff --git a/src/WixTestTools/WixTestContext.cs b/src/WixTestTools/WixTestContext.cs
index c00f5723..a4e666f1 100644
--- a/src/WixTestTools/WixTestContext.cs
+++ b/src/WixTestTools/WixTestContext.cs
@@ -42,9 +42,10 @@ namespace WixTestTools
42 /// <remarks> 42 /// <remarks>
43 /// The package or bundle must install into [ProgramFilesFolder]\~Test WiX\[TestGroupName]\([Additional]). 43 /// The package or bundle must install into [ProgramFilesFolder]\~Test WiX\[TestGroupName]\([Additional]).
44 /// </remarks> 44 /// </remarks>
45 public string GetTestInstallFolder(string additionalPath = null) 45 public string GetTestInstallFolder(bool x64, string additionalPath = null)
46 { 46 {
47 return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "~Test WiX", this.TestGroupName, additionalPath ?? String.Empty); 47 var baseDirectory = x64 ? Environment.SpecialFolder.ProgramFiles : Environment.SpecialFolder.ProgramFilesX86;
48 return Path.Combine(Environment.GetFolderPath(baseDirectory), "~Test WiX", this.TestGroupName, additionalPath ?? String.Empty);
48 } 49 }
49 50
50 /// <summary> 51 /// <summary>
@@ -55,9 +56,10 @@ namespace WixTestTools
55 /// <remarks> 56 /// <remarks>
56 /// The package must write into HKLM\Software\WiX\Tests\[TestGroupName]\([Additional]). 57 /// The package must write into HKLM\Software\WiX\Tests\[TestGroupName]\([Additional]).
57 /// </remarks> 58 /// </remarks>
58 public RegistryKey GetTestRegistryRoot(string additionalPath = null) 59 public RegistryKey GetTestRegistryRoot(bool x64, string additionalPath = null)
59 { 60 {
60 var key = String.Format(@"Software\WOW6432Node\WiX\Tests\{0}\{1}", this.TestGroupName, additionalPath ?? String.Empty); 61 var baseKey = x64 ? "Software" : @"Software\WOW6432Node";
62 var key = String.Format(@"{0}\WiX\Tests\{1}\{2}", baseKey, this.TestGroupName, additionalPath ?? String.Empty);
61 return Registry.LocalMachine.OpenSubKey(key, true); 63 return Registry.LocalMachine.OpenSubKey(key, true);
62 } 64 }
63 65