public void CanTrack1ForwardCompatibleDependentThroughMajorUpgrade()
        {
            string providerId   = BundleAProviderId;
            string parent       = "~BundleAv1";
            string parentSwitch = String.Concat("-parent ", parent);

            var packageAv1 = this.CreatePackageInstaller("PackageAv1");
            var packageAv2 = this.CreatePackageInstaller("PackageAv2");
            var bundleAv1  = this.CreateBundleInstaller("BundleAv1");
            var bundleAv2  = this.CreateBundleInstaller("BundleAv2");

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(false);

            // Install the v1 bundle with a parent.
            bundleAv1.Install(arguments: parentSwitch);
            bundleAv1.VerifyRegisteredAndInPackageCache();

            packageAv1.VerifyInstalled(true);
            packageAv2.VerifyInstalled(false);
            Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
            Assert.Equal(V100, actualProviderVersion);
            Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));

            // Upgrade with the v2 bundle.
            bundleAv2.Install();
            bundleAv2.VerifyRegisteredAndInPackageCache();
            bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(true);
            Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
            Assert.Equal(V200, actualProviderVersion);
            Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));

            // Uninstall the v2 bundle and nothing should happen because there is still a parent.
            bundleAv2.Uninstall();
            bundleAv2.VerifyRegisteredAndInPackageCache();

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(true);
            Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
            Assert.Equal(V200, actualProviderVersion);
            Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));

            // Uninstall the v1 bundle with passthrough and all should be removed.
            bundleAv1.Uninstall(arguments: parentSwitch);
            bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
            bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(false);
            Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
        }
        public void CanUninstallForwardCompatibleWithBundlesUninstalledInReverseOrder()
        {
            string providerId   = BundleAProviderId;
            string parent       = "~BundleAv1";
            string parentSwitch = String.Concat("-parent ", parent);

            var packageAv1 = this.CreatePackageInstaller("PackageAv1");
            var packageAv2 = this.CreatePackageInstaller("PackageAv2");
            var bundleAv1  = this.CreateBundleInstaller("BundleAv1");
            var bundleAv2  = this.CreateBundleInstaller("BundleAv2");

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(false);

            bundleAv2.Install();
            bundleAv2.VerifyRegisteredAndInPackageCache();

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(true);
            Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
            Assert.Equal(V200, actualProviderVersion);

            // Install the v1 bundle with a parent which should passthrough to v2.
            bundleAv1.Install(arguments: parentSwitch);
            bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(true);
            Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));

            // Uninstall the v1 bundle with the same parent which should passthrough to v2 and remove parent.
            bundleAv1.Uninstall(arguments: parentSwitch);
            bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
            bundleAv2.VerifyRegisteredAndInPackageCache();

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(true);
            Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent));

            // Uninstall the v2 bundle and all should be removed.
            bundleAv2.Uninstall();
            bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();

            packageAv1.VerifyInstalled(false);
            packageAv2.VerifyInstalled(false);
            Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
        }