| 1 | // 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. |
| 2 | |
| 3 | namespace WixToolsetTest.BurnE2E |
| 4 | { |
| 5 | using System; |
| 6 | using System.IO; |
| 7 | using WixTestTools; |
| 8 | using Xunit; |
| 9 | using Xunit.Abstractions; |
| 10 | |
| 11 | public class ForwardCompatibleBundleTests : BurnE2ETests |
| 12 | { |
| 13 | public ForwardCompatibleBundleTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } |
| 14 | |
| 15 | private const string BundleAProviderId = "~" + nameof(ForwardCompatibleBundleTests) + "_BundleA"; |
| 16 | private const string BundleCProviderId = "~" + nameof(ForwardCompatibleBundleTests) + "_BundleC"; |
| 17 | private const string V100 = "1.0.0.0"; |
| 18 | private const string V200 = "2.0.0.0"; |
| 19 | |
| 20 | [RuntimeFact] |
| 21 | public void CanIgnoreBundleDependentForUnsafeUninstall() |
| 22 | { |
| 23 | string providerId = BundleAProviderId; |
| 24 | string parent = "~BundleAv1"; |
| 25 | string parentSwitch = String.Concat("-parent ", parent); |
| 26 | |
| 27 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); |
| 28 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); |
| 29 | var testBAController = this.CreateTestBAController(); |
| 30 | |
| 31 | packageAv1.VerifyInstalled(false); |
| 32 | |
| 33 | // Install the v1 bundle with a parent. |
| 34 | bundleAv1.Install(arguments: parentSwitch); |
| 35 | bundleAv1.VerifyRegisteredAndInPackageCache(); |
| 36 | |
| 37 | packageAv1.VerifyInstalled(true); |
| 38 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 39 | Assert.Equal(V100, actualProviderVersion); |
| 40 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 41 | |
| 42 | // Cancel package B right away. |
| 43 | testBAController.SetPackageCancelExecuteAtProgress("PackageA", 1); |
| 44 | |
| 45 | bundleAv1.UnsafeUninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT); |
| 46 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 47 | |
| 48 | packageAv1.VerifyInstalled(true); |
| 49 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 50 | } |
| 51 | |
| 52 | [RuntimeFact] |
| 53 | public void CanTrack1ForwardCompatibleDependentThroughMajorUpgrade() |
| 54 | { |
| 55 | string providerId = BundleAProviderId; |
| 56 | string parent = "~BundleAv1"; |
| 57 | string parentSwitch = String.Concat("-parent ", parent); |
| 58 | |
| 59 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); |
| 60 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); |
| 61 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); |
| 62 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); |
| 63 | |
| 64 | packageAv1.VerifyInstalled(false); |
| 65 | packageAv2.VerifyInstalled(false); |
| 66 | |
| 67 | // Install the v1 bundle with a parent. |
| 68 | bundleAv1.Install(arguments: parentSwitch); |
| 69 | bundleAv1.VerifyRegisteredAndInPackageCache(); |
| 70 | |
| 71 | packageAv1.VerifyInstalled(true); |
| 72 | packageAv2.VerifyInstalled(false); |
| 73 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 74 | Assert.Equal(V100, actualProviderVersion); |
| 75 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 76 | |
| 77 | // Upgrade with the v2 bundle. |
| 78 | bundleAv2.Install(); |
| 79 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 80 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 81 | |
| 82 | packageAv1.VerifyInstalled(false); |
| 83 | packageAv2.VerifyInstalled(true); |
| 84 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 85 | Assert.Equal(V200, actualProviderVersion); |
| 86 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 87 | |
| 88 | // Uninstall the v2 bundle and nothing should happen because there is still a parent. |
| 89 | bundleAv2.Uninstall(); |
| 90 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 91 | |
| 92 | packageAv1.VerifyInstalled(false); |
| 93 | packageAv2.VerifyInstalled(true); |
| 94 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 95 | Assert.Equal(V200, actualProviderVersion); |
| 96 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 97 | |
| 98 | // Uninstall the v1 bundle with passthrough and all should be removed. |
| 99 | bundleAv1.Uninstall(arguments: parentSwitch); |
| 100 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 101 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 102 | |
| 103 | packageAv1.VerifyInstalled(false); |
| 104 | packageAv2.VerifyInstalled(false); |
| 105 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 106 | } |
| 107 | |
| 108 | [RuntimeFact] |
| 109 | public void CanTrack1ForwardCompatibleDependentThroughMajorUpgradeWithParentNone() |
| 110 | { |
| 111 | string providerId = BundleAProviderId; |
| 112 | string parent = "~BundleAv1"; |
| 113 | string parentSwitch = String.Concat("-parent ", parent); |
| 114 | |
| 115 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); |
| 116 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); |
| 117 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); |
| 118 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); |
| 119 | |
| 120 | packageAv1.VerifyInstalled(false); |
| 121 | packageAv2.VerifyInstalled(false); |
| 122 | |
| 123 | // Install the v1 bundle with a parent. |
| 124 | bundleAv1.Install(arguments: parentSwitch); |
| 125 | bundleAv1.VerifyRegisteredAndInPackageCache(); |
| 126 | |
| 127 | packageAv1.VerifyInstalled(true); |
| 128 | packageAv2.VerifyInstalled(false); |
| 129 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 130 | Assert.Equal(V100, actualProviderVersion); |
| 131 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 132 | |
| 133 | // Upgrade with the v2 bundle but prevent self parent being registered. |
| 134 | bundleAv2.Install(arguments: "-parent:none"); |
| 135 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 136 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 137 | |
| 138 | packageAv1.VerifyInstalled(false); |
| 139 | packageAv2.VerifyInstalled(true); |
| 140 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 141 | Assert.Equal(V200, actualProviderVersion); |
| 142 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 143 | |
| 144 | // Uninstall the v1 bundle with passthrough and all should be removed. |
| 145 | bundleAv1.Uninstall(arguments: parentSwitch); |
| 146 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 147 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 148 | |
| 149 | packageAv1.VerifyInstalled(false); |
| 150 | packageAv2.VerifyInstalled(false); |
| 151 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 152 | } |
| 153 | |
| 154 | [RuntimeFact] |
| 155 | public void CanTrack2ForwardCompatibleDependentsThroughMajorUpgrade() |
| 156 | { |
| 157 | string providerId = BundleAProviderId; |
| 158 | string parent = "~BundleAv1"; |
| 159 | string parent2 = "~BundleAv1_Parent2"; |
| 160 | string parentSwitch = String.Concat("-parent ", parent); |
| 161 | string parent2Switch = String.Concat("-parent ", parent2); |
| 162 | |
| 163 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); |
| 164 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); |
| 165 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); |
| 166 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); |
| 167 | |
| 168 | packageAv1.VerifyInstalled(false); |
| 169 | packageAv2.VerifyInstalled(false); |
| 170 | |
| 171 | // Install the v1 bundle with a parent. |
| 172 | bundleAv1.Install(arguments: parentSwitch); |
| 173 | bundleAv1.VerifyRegisteredAndInPackageCache(); |
| 174 | |
| 175 | packageAv1.VerifyInstalled(true); |
| 176 | packageAv2.VerifyInstalled(false); |
| 177 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 178 | Assert.Equal(V100, actualProviderVersion); |
| 179 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 180 | |
| 181 | // Install the v1 bundle with a second parent. |
| 182 | bundleAv1.Install(arguments: parent2Switch); |
| 183 | bundleAv1.VerifyRegisteredAndInPackageCache(); |
| 184 | |
| 185 | packageAv1.VerifyInstalled(true); |
| 186 | packageAv2.VerifyInstalled(false); |
| 187 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 188 | Assert.Equal(V100, actualProviderVersion); |
| 189 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 190 | |
| 191 | // Upgrade with the v2 bundle. |
| 192 | bundleAv2.Install(); |
| 193 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 194 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 195 | |
| 196 | packageAv1.VerifyInstalled(false); |
| 197 | packageAv2.VerifyInstalled(true); |
| 198 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 199 | Assert.Equal(V200, actualProviderVersion); |
| 200 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 201 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 202 | |
| 203 | // Uninstall the v2 bundle and nothing should happen because there is still a parent. |
| 204 | bundleAv2.Uninstall(); |
| 205 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 206 | |
| 207 | packageAv1.VerifyInstalled(false); |
| 208 | packageAv2.VerifyInstalled(true); |
| 209 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 210 | Assert.Equal(V200, actualProviderVersion); |
| 211 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 212 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 213 | |
| 214 | // Uninstall one parent of the v1 bundle and nothing should happen because there is still a parent. |
| 215 | bundleAv1.Uninstall(arguments: parentSwitch); |
| 216 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 217 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 218 | |
| 219 | packageAv1.VerifyInstalled(false); |
| 220 | packageAv2.VerifyInstalled(true); |
| 221 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 222 | Assert.Equal(V200, actualProviderVersion); |
| 223 | Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 224 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 225 | |
| 226 | // Uninstall the v1 bundle with passthrough with second parent and all should be removed. |
| 227 | bundleAv1.Uninstall(arguments: parent2Switch); |
| 228 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 229 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 230 | |
| 231 | packageAv1.VerifyInstalled(false); |
| 232 | packageAv2.VerifyInstalled(false); |
| 233 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 234 | } |
| 235 | |
| 236 | [RuntimeFact] |
| 237 | public void CanTrack2ForwardCompatibleDependentsThroughMajorUpgradePerUser() |
| 238 | { |
| 239 | string providerId = BundleCProviderId; |
| 240 | string parent = "~BundleCv1"; |
| 241 | string parent2 = "~BundleCv1_Parent2"; |
| 242 | string parentSwitch = String.Concat("-parent ", parent); |
| 243 | string parent2Switch = String.Concat("-parent ", parent2); |
| 244 | |
| 245 | var packageCv1 = this.CreatePackageInstaller("PackageCv1"); |
| 246 | var packageCv2 = this.CreatePackageInstaller("PackageCv2"); |
| 247 | var bundleCv1 = this.CreateBundleInstaller("BundleCv1"); |
| 248 | var bundleCv2 = this.CreateBundleInstaller("BundleCv2"); |
| 249 | |
| 250 | packageCv1.VerifyInstalled(false); |
| 251 | packageCv2.VerifyInstalled(false); |
| 252 | |
| 253 | // Install the v1 bundle with a parent. |
| 254 | bundleCv1.Install(arguments: parentSwitch); |
| 255 | bundleCv1.VerifyRegisteredAndInPackageCache(); |
| 256 | |
| 257 | packageCv1.VerifyInstalled(true); |
| 258 | packageCv2.VerifyInstalled(false); |
| 259 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 260 | Assert.Equal(V100, actualProviderVersion); |
| 261 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 262 | |
| 263 | // Install the v1 bundle with a second parent. |
| 264 | bundleCv1.Install(arguments: parent2Switch); |
| 265 | bundleCv1.VerifyRegisteredAndInPackageCache(); |
| 266 | |
| 267 | packageCv1.VerifyInstalled(true); |
| 268 | packageCv2.VerifyInstalled(false); |
| 269 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 270 | Assert.Equal(V100, actualProviderVersion); |
| 271 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 272 | |
| 273 | // Upgrade with the v2 bundle. |
| 274 | bundleCv2.Install(); |
| 275 | bundleCv2.VerifyRegisteredAndInPackageCache(); |
| 276 | bundleCv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 277 | |
| 278 | packageCv1.VerifyInstalled(false); |
| 279 | packageCv2.VerifyInstalled(true); |
| 280 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 281 | Assert.Equal(V200, actualProviderVersion); |
| 282 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 283 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 284 | |
| 285 | // Uninstall the v2 bundle and nothing should happen because there is still a parent. |
| 286 | bundleCv2.Uninstall(); |
| 287 | bundleCv2.VerifyRegisteredAndInPackageCache(); |
| 288 | |
| 289 | packageCv1.VerifyInstalled(false); |
| 290 | packageCv2.VerifyInstalled(true); |
| 291 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 292 | Assert.Equal(V200, actualProviderVersion); |
| 293 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 294 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 295 | |
| 296 | // Uninstall one parent of the v1 bundle and nothing should happen because there is still a parent. |
| 297 | bundleCv1.Uninstall(arguments: parentSwitch); |
| 298 | bundleCv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 299 | bundleCv2.VerifyRegisteredAndInPackageCache(); |
| 300 | |
| 301 | packageCv1.VerifyInstalled(false); |
| 302 | packageCv2.VerifyInstalled(true); |
| 303 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 304 | Assert.Equal(V200, actualProviderVersion); |
| 305 | Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 306 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 307 | |
| 308 | // Uninstall the v1 bundle with passthrough with second parent and all should be removed. |
| 309 | bundleCv1.Uninstall(arguments: parent2Switch); |
| 310 | bundleCv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 311 | bundleCv2.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 312 | |
| 313 | packageCv1.VerifyInstalled(false); |
| 314 | packageCv2.VerifyInstalled(false); |
| 315 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 316 | } |
| 317 | |
| 318 | [RuntimeFact] |
| 319 | public void CanTrack2ForwardCompatibleDependentsThroughMajorUpgradeWithParent() |
| 320 | { |
| 321 | string providerId = BundleAProviderId; |
| 322 | string parent = "~BundleAv1"; |
| 323 | string parent2 = "~BundleAv1_Parent2"; |
| 324 | string parent3 = "~BundleAv1_Parent3"; |
| 325 | string parentSwitch = String.Concat("-parent ", parent); |
| 326 | string parent2Switch = String.Concat("-parent ", parent2); |
| 327 | string parent3Switch = String.Concat("-parent ", parent3); |
| 328 | |
| 329 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); |
| 330 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); |
| 331 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); |
| 332 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); |
| 333 | |
| 334 | packageAv1.VerifyInstalled(false); |
| 335 | packageAv2.VerifyInstalled(false); |
| 336 | |
| 337 | // Install the v1 bundle with a parent. |
| 338 | bundleAv1.Install(arguments: parentSwitch); |
| 339 | bundleAv1.VerifyRegisteredAndInPackageCache(); |
| 340 | |
| 341 | packageAv1.VerifyInstalled(true); |
| 342 | packageAv2.VerifyInstalled(false); |
| 343 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 344 | Assert.Equal(V100, actualProviderVersion); |
| 345 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 346 | |
| 347 | // Install the v1 bundle with a second parent. |
| 348 | bundleAv1.Install(arguments: parent2Switch); |
| 349 | bundleAv1.VerifyRegisteredAndInPackageCache(); |
| 350 | |
| 351 | packageAv1.VerifyInstalled(true); |
| 352 | packageAv2.VerifyInstalled(false); |
| 353 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 354 | Assert.Equal(V100, actualProviderVersion); |
| 355 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 356 | |
| 357 | // Upgrade with the v2 bundle. |
| 358 | bundleAv2.Install(arguments: parent3Switch); |
| 359 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 360 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 361 | |
| 362 | packageAv1.VerifyInstalled(false); |
| 363 | packageAv2.VerifyInstalled(true); |
| 364 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 365 | Assert.Equal(V200, actualProviderVersion); |
| 366 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 367 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 368 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent3)); |
| 369 | |
| 370 | // Uninstall the v2 bundle and nothing should happen because there is still a parent. |
| 371 | bundleAv2.Uninstall(arguments: parent3Switch); |
| 372 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 373 | |
| 374 | packageAv1.VerifyInstalled(false); |
| 375 | packageAv2.VerifyInstalled(true); |
| 376 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 377 | Assert.Equal(V200, actualProviderVersion); |
| 378 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 379 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 380 | Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent3)); |
| 381 | |
| 382 | // Uninstall one parent of the v1 bundle and nothing should happen because there is still a parent. |
| 383 | bundleAv1.Uninstall(arguments: parentSwitch); |
| 384 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 385 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 386 | |
| 387 | packageAv1.VerifyInstalled(false); |
| 388 | packageAv2.VerifyInstalled(true); |
| 389 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); |
| 390 | Assert.Equal(V200, actualProviderVersion); |
| 391 | Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 392 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2)); |
| 393 | |
| 394 | // Uninstall the v1 bundle with passthrough with second parent and all should be removed. |
| 395 | bundleAv1.Uninstall(arguments: parent2Switch); |
| 396 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 397 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 398 | |
| 399 | packageAv1.VerifyInstalled(false); |
| 400 | packageAv2.VerifyInstalled(false); |
| 401 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 402 | } |
| 403 | |
| 404 | [RuntimeFact] |
| 405 | public void CanUninstallForwardCompatibleWithBundlesUninstalledInFifoOrder() |
| 406 | { |
| 407 | string providerId = BundleAProviderId; |
| 408 | string parent = "~BundleAv1"; |
| 409 | string parentSwitch = String.Concat("-parent ", parent); |
| 410 | |
| 411 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); |
| 412 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); |
| 413 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); |
| 414 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); |
| 415 | |
| 416 | packageAv1.VerifyInstalled(false); |
| 417 | packageAv2.VerifyInstalled(false); |
| 418 | |
| 419 | bundleAv2.Install(); |
| 420 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 421 | |
| 422 | packageAv1.VerifyInstalled(false); |
| 423 | packageAv2.VerifyInstalled(true); |
| 424 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 425 | Assert.Equal(V200, actualProviderVersion); |
| 426 | |
| 427 | // Install the v1 bundle with a parent which should passthrough to v2. |
| 428 | bundleAv1.Install(arguments: parentSwitch); |
| 429 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 430 | |
| 431 | packageAv1.VerifyInstalled(false); |
| 432 | packageAv2.VerifyInstalled(true); |
| 433 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 434 | |
| 435 | bundleAv2.Uninstall(); |
| 436 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 437 | |
| 438 | packageAv1.VerifyInstalled(false); |
| 439 | packageAv2.VerifyInstalled(true); |
| 440 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 441 | |
| 442 | // Uninstall the v1 bundle with passthrough and all should be removed. |
| 443 | bundleAv1.Uninstall(arguments: parentSwitch); |
| 444 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 445 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 446 | |
| 447 | packageAv1.VerifyInstalled(false); |
| 448 | packageAv2.VerifyInstalled(false); |
| 449 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 450 | } |
| 451 | |
| 452 | [RuntimeFact] |
| 453 | public void CanUninstallForwardCompatibleWithBundlesUninstalledInReverseOrder() |
| 454 | { |
| 455 | string providerId = BundleAProviderId; |
| 456 | string parent = "~BundleAv1"; |
| 457 | string parentSwitch = String.Concat("-parent ", parent); |
| 458 | |
| 459 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); |
| 460 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); |
| 461 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); |
| 462 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); |
| 463 | |
| 464 | packageAv1.VerifyInstalled(false); |
| 465 | packageAv2.VerifyInstalled(false); |
| 466 | |
| 467 | bundleAv2.Install(); |
| 468 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 469 | |
| 470 | packageAv1.VerifyInstalled(false); |
| 471 | packageAv2.VerifyInstalled(true); |
| 472 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); |
| 473 | Assert.Equal(V200, actualProviderVersion); |
| 474 | |
| 475 | // Install the v1 bundle with a parent which should passthrough to v2. |
| 476 | bundleAv1.Install(arguments: parentSwitch); |
| 477 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 478 | |
| 479 | packageAv1.VerifyInstalled(false); |
| 480 | packageAv2.VerifyInstalled(true); |
| 481 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 482 | |
| 483 | // Uninstall the v1 bundle with the same parent which should passthrough to v2 and remove parent. |
| 484 | bundleAv1.Uninstall(arguments: parentSwitch); |
| 485 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 486 | bundleAv2.VerifyRegisteredAndInPackageCache(); |
| 487 | |
| 488 | packageAv1.VerifyInstalled(false); |
| 489 | packageAv2.VerifyInstalled(true); |
| 490 | Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent)); |
| 491 | |
| 492 | // Uninstall the v2 bundle and all should be removed. |
| 493 | bundleAv2.Uninstall(); |
| 494 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 495 | |
| 496 | packageAv1.VerifyInstalled(false); |
| 497 | packageAv2.VerifyInstalled(false); |
| 498 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 499 | } |
| 500 | } |
| 501 | } |