diff options
Diffstat (limited to '')
-rw-r--r-- | src/WixToolsetTest.BurnE2E/BundleInstaller.cs | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/src/WixToolsetTest.BurnE2E/BundleInstaller.cs b/src/WixToolsetTest.BurnE2E/BundleInstaller.cs index c85646bb..5ce993f3 100644 --- a/src/WixToolsetTest.BurnE2E/BundleInstaller.cs +++ b/src/WixToolsetTest.BurnE2E/BundleInstaller.cs | |||
@@ -15,6 +15,8 @@ namespace WixToolsetTest.BurnE2E | |||
15 | { | 15 | { |
16 | public const string BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | 16 | public const string BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; |
17 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH = "BundleCachePath"; | 17 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH = "BundleCachePath"; |
18 | public const string FULL_BURN_POLICY_REGISTRY_PATH = "SOFTWARE\\WOW6432Node\\Policies\\WiX\\Burn"; | ||
19 | public const string PACKAGE_CACHE_FOLDER_NAME = "Package Cache"; | ||
18 | 20 | ||
19 | public BundleInstaller(WixTestContext testContext, string name) | 21 | public BundleInstaller(WixTestContext testContext, string name) |
20 | { | 22 | { |
@@ -28,6 +30,8 @@ namespace WixToolsetTest.BurnE2E | |||
28 | 30 | ||
29 | public string BundlePdb { get; } | 31 | public string BundlePdb { get; } |
30 | 32 | ||
33 | private WixBundleSymbol BundleSymbol { get; set; } | ||
34 | |||
31 | public string TestGroupName { get; } | 35 | public string TestGroupName { get; } |
32 | 36 | ||
33 | public string TestName { get; } | 37 | public string TestName { get; } |
@@ -142,37 +146,63 @@ namespace WixToolsetTest.BurnE2E | |||
142 | return logFile; | 146 | return logFile; |
143 | } | 147 | } |
144 | 148 | ||
149 | private WixBundleSymbol GetBundleSymbol() | ||
150 | { | ||
151 | if (this.BundleSymbol == null) | ||
152 | { | ||
153 | using var wixOutput = WixOutput.Read(this.BundlePdb); | ||
154 | var intermediate = Intermediate.Load(wixOutput); | ||
155 | var section = intermediate.Sections.Single(); | ||
156 | this.BundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); | ||
157 | } | ||
158 | |||
159 | return this.BundleSymbol; | ||
160 | } | ||
161 | |||
162 | public string GetExpectedCachedBundlePath() | ||
163 | { | ||
164 | var bundleSymbol = this.GetBundleSymbol(); | ||
165 | |||
166 | using var policyKey = Registry.LocalMachine.OpenSubKey(FULL_BURN_POLICY_REGISTRY_PATH); | ||
167 | var redirectedCachePath = policyKey?.GetValue("PackageCache") as string; | ||
168 | var cachePath = redirectedCachePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), PACKAGE_CACHE_FOLDER_NAME); | ||
169 | return Path.Combine(cachePath, bundleSymbol.BundleId, Path.GetFileName(this.Bundle)); | ||
170 | } | ||
171 | |||
145 | public string VerifyRegisteredAndInPackageCache() | 172 | public string VerifyRegisteredAndInPackageCache() |
146 | { | 173 | { |
147 | using var wixOutput = WixOutput.Read(this.BundlePdb); | 174 | var bundleSymbol = this.GetBundleSymbol(); |
148 | var intermediate = Intermediate.Load(wixOutput); | ||
149 | var section = intermediate.Sections.Single(); | ||
150 | var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); | ||
151 | var bundleId = bundleSymbol.BundleId; | 175 | var bundleId = bundleSymbol.BundleId; |
152 | var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY}\\{bundleId}"; | 176 | var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY}\\{bundleId}"; |
153 | 177 | ||
154 | using var testKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); | 178 | using var registrationKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); |
155 | Assert.NotNull(testKey); | 179 | Assert.NotNull(registrationKey); |
156 | 180 | ||
157 | var cachePathValue = testKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH); | 181 | var cachePathValue = registrationKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH); |
158 | Assert.NotNull(cachePathValue); | 182 | Assert.NotNull(cachePathValue); |
159 | var cachePath = Assert.IsType<string>(cachePathValue); | 183 | var cachePath = Assert.IsType<string>(cachePathValue); |
160 | Assert.True(File.Exists(cachePath)); | 184 | Assert.True(File.Exists(cachePath)); |
161 | 185 | ||
186 | var expectedCachePath = this.GetExpectedCachedBundlePath(); | ||
187 | Assert.Equal(expectedCachePath, cachePath, StringComparer.OrdinalIgnoreCase); | ||
188 | |||
162 | return cachePath; | 189 | return cachePath; |
163 | } | 190 | } |
164 | 191 | ||
192 | public void VerifyUnregisteredAndRemovedFromPackageCache() | ||
193 | { | ||
194 | var cachedBundlePath = this.GetExpectedCachedBundlePath(); | ||
195 | this.VerifyUnregisteredAndRemovedFromPackageCache(cachedBundlePath); | ||
196 | } | ||
197 | |||
165 | public void VerifyUnregisteredAndRemovedFromPackageCache(string cachedBundlePath) | 198 | public void VerifyUnregisteredAndRemovedFromPackageCache(string cachedBundlePath) |
166 | { | 199 | { |
167 | using var wixOutput = WixOutput.Read(this.BundlePdb); | 200 | var bundleSymbol = this.GetBundleSymbol(); |
168 | var intermediate = Intermediate.Load(wixOutput); | ||
169 | var section = intermediate.Sections.Single(); | ||
170 | var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); | ||
171 | var bundleId = bundleSymbol.BundleId; | 201 | var bundleId = bundleSymbol.BundleId; |
172 | var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY}\\{bundleId}"; | 202 | var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY}\\{bundleId}"; |
173 | 203 | ||
174 | using var testKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); | 204 | using var registrationKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); |
175 | Assert.Null(testKey); | 205 | Assert.Null(registrationKey); |
176 | 206 | ||
177 | Assert.False(File.Exists(cachedBundlePath)); | 207 | Assert.False(File.Exists(cachedBundlePath)); |
178 | } | 208 | } |