@joebigelow / wix / commits / 81908a5e

Port forward compatible tests from old repo.

Sean Hall committed Mar 11, 2021 at 17:54 UTC 81908a5ec1647d76b45f50e4a18c37e1544818be
21 files changed +794
src/TestData/ForwardCompatibleBundleTests/BundleAv1/Bundle.wxs new
+40
@@ -0,0 +1,40 @@
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 +<?ifndef Version?>
4 +<?define Version = 1.0.0.0?>
5 +<?endif?>
6 +
7 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
8 + <!-- ProviderKey should be the only thing different from the template -->
9 + <Bundle Name="~$(var.TestGroupName) - $(var.BundleName)" Version="$(var.Version)" UpgradeCode="$(var.UpgradeCode)" Compressed="yes" ProviderKey="~$(var.TestGroupName)_BundleA">
10 + <Log Prefix="~$(var.TestGroupName)_$(var.BundleName)" />
11 +
12 + <Variable Name="TestGroupName" Value="$(var.TestGroupName)" />
13 +
14 + <?ifdef SoftwareTag?>
15 + <SoftwareTag Regid="regid.1995-08.com.example" InstallPath="[CommonAppDataFolder]regid.1995-08.com.example" />
16 + <?endif?>
17 +
18 + <?ifndef BA?>
19 + <!-- pulled in through the PackageGroupRef below -->
20 + <?elseif $(var.BA) = "TestBAdnc"?>
21 + <!-- pulled in through the PackageGroupRef below -->
22 + <?elseif $(var.BA) = "hyperlinkLicense"?>
23 + <BootstrapperApplication>
24 + <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" />
25 + </BootstrapperApplication>
26 + <?else?>
27 + <BootstrapperApplicationRef Id="$(var.BA)" />
28 + <?endif?>
29 +
30 + <Chain>
31 + <?ifndef BA?>
32 + <PackageGroupRef Id="TestBA" />
33 + <?elseif $(var.BA) = "TestBAdnc"?>
34 + <PackageGroupRef Id="TestBAdnc" />
35 + <?endif?>
36 +
37 + <PackageGroupRef Id="BundlePackages" />
38 + </Chain>
39 + </Bundle>
40 +</Wix>
src/TestData/ForwardCompatibleBundleTests/BundleAv1/BundleA.props new
+7
@@ -0,0 +1,7 @@
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 +<Project>
3 + <PropertyGroup>
4 + <OutputType>Bundle</OutputType>
5 + <UpgradeCode>{5ACFAE02-DDF0-4F1C-BEAD-1E0998E5CF9B}</UpgradeCode>
6 + </PropertyGroup>
7 +</Project>
src/TestData/ForwardCompatibleBundleTests/BundleAv1/BundleAv1.wixproj new
+12
@@ -0,0 +1,12 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="BundleA.props" />
4 + <ItemGroup>
5 + <ProjectReference Include="..\PackageAv1\PackageAv1.wixproj" />
6 + <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
7 + </ItemGroup>
8 + <ItemGroup>
9 + <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.89" />
10 + <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.64" />
11 + </ItemGroup>
12 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/BundleAv1/BundleAv1.wxs new
+10
@@ -0,0 +1,10 @@
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 +
4 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
5 + <Fragment>
6 + <PackageGroup Id="BundlePackages">
7 + <MsiPackage Id="PackageA" SourceFile="$(var.PackageAv1.TargetPath)" />
8 + </PackageGroup>
9 + </Fragment>
10 +</Wix>
src/TestData/ForwardCompatibleBundleTests/BundleAv2/BundleAv2.wixproj new
+18
@@ -0,0 +1,18 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="..\BundleAv1\BundleA.props" />
4 + <PropertyGroup>
5 + <Version>2.0.0.0</Version>
6 + </PropertyGroup>
7 + <ItemGroup>
8 + <Compile Include="..\BundleAv1\Bundle.wxs" />
9 + </ItemGroup>
10 + <ItemGroup>
11 + <ProjectReference Include="..\PackageAv2\PackageAv2.wixproj" />
12 + <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
13 + </ItemGroup>
14 + <ItemGroup>
15 + <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.89" />
16 + <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.64" />
17 + </ItemGroup>
18 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/BundleAv2/BundleAv2.wxs new
+10
@@ -0,0 +1,10 @@
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 +
4 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
5 + <Fragment>
6 + <PackageGroup Id="BundlePackages">
7 + <MsiPackage Id="PackageA" SourceFile="$(var.PackageAv2.TargetPath)" />
8 + </PackageGroup>
9 + </Fragment>
10 +</Wix>
src/TestData/ForwardCompatibleBundleTests/BundleCv1/Bundle.wxs new
+40
@@ -0,0 +1,40 @@
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 +<?ifndef Version?>
4 +<?define Version = 1.0.0.0?>
5 +<?endif?>
6 +
7 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
8 + <!-- ProviderKey should be the only thing different from the template -->
9 + <Bundle Name="~$(var.TestGroupName) - $(var.BundleName)" Version="$(var.Version)" UpgradeCode="$(var.UpgradeCode)" Compressed="yes" ProviderKey="~$(var.TestGroupName)_BundleC">
10 + <Log Prefix="~$(var.TestGroupName)_$(var.BundleName)" />
11 +
12 + <Variable Name="TestGroupName" Value="$(var.TestGroupName)" />
13 +
14 + <?ifdef SoftwareTag?>
15 + <SoftwareTag Regid="regid.1995-08.com.example" InstallPath="[CommonAppDataFolder]regid.1995-08.com.example" />
16 + <?endif?>
17 +
18 + <?ifndef BA?>
19 + <!-- pulled in through the PackageGroupRef below -->
20 + <?elseif $(var.BA) = "TestBAdnc"?>
21 + <!-- pulled in through the PackageGroupRef below -->
22 + <?elseif $(var.BA) = "hyperlinkLicense"?>
23 + <BootstrapperApplication>
24 + <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" />
25 + </BootstrapperApplication>
26 + <?else?>
27 + <BootstrapperApplicationRef Id="$(var.BA)" />
28 + <?endif?>
29 +
30 + <Chain>
31 + <?ifndef BA?>
32 + <PackageGroupRef Id="TestBA" />
33 + <?elseif $(var.BA) = "TestBAdnc"?>
34 + <PackageGroupRef Id="TestBAdnc" />
35 + <?endif?>
36 +
37 + <PackageGroupRef Id="BundlePackages" />
38 + </Chain>
39 + </Bundle>
40 +</Wix>
src/TestData/ForwardCompatibleBundleTests/BundleCv1/BundleC.props new
+7
@@ -0,0 +1,7 @@
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 +<Project>
3 + <PropertyGroup>
4 + <OutputType>Bundle</OutputType>
5 + <UpgradeCode>{D387D602-533C-495D-B14E-AA9D46AF314B}</UpgradeCode>
6 + </PropertyGroup>
7 +</Project>
src/TestData/ForwardCompatibleBundleTests/BundleCv1/BundleCv1.wixproj new
+12
@@ -0,0 +1,12 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="BundleC.props" />
4 + <ItemGroup>
5 + <ProjectReference Include="..\PackageCv1\PackageCv1.wixproj" />
6 + <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
7 + </ItemGroup>
8 + <ItemGroup>
9 + <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.89" />
10 + <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.64" />
11 + </ItemGroup>
12 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/BundleCv1/BundleCv1.wxs new
+10
@@ -0,0 +1,10 @@
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 +
4 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
5 + <Fragment>
6 + <PackageGroup Id="BundlePackages">
7 + <MsiPackage Id="PackageC" SourceFile="$(var.PackageCv1.TargetPath)" />
8 + </PackageGroup>
9 + </Fragment>
10 +</Wix>
src/TestData/ForwardCompatibleBundleTests/BundleCv2/BundleCv2.wixproj new
+18
@@ -0,0 +1,18 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="..\BundleCv1\BundleC.props" />
4 + <PropertyGroup>
5 + <Version>2.0.0.0</Version>
6 + </PropertyGroup>
7 + <ItemGroup>
8 + <Compile Include="..\BundleCv1\Bundle.wxs" />
9 + </ItemGroup>
10 + <ItemGroup>
11 + <ProjectReference Include="..\PackageCv2\PackageCv2.wixproj" />
12 + <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
13 + </ItemGroup>
14 + <ItemGroup>
15 + <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.89" />
16 + <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.64" />
17 + </ItemGroup>
18 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/BundleCv2/BundleCv2.wxs new
+10
@@ -0,0 +1,10 @@
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 +
4 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
5 + <Fragment>
6 + <PackageGroup Id="BundlePackages">
7 + <MsiPackage Id="PackageC" SourceFile="$(var.PackageCv2.TargetPath)" />
8 + </PackageGroup>
9 + </Fragment>
10 +</Wix>
src/TestData/ForwardCompatibleBundleTests/PackageAv1/PackageA.props new
+9
@@ -0,0 +1,9 @@
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 +<Project>
3 + <PropertyGroup>
4 + <UpgradeCode>{F764127F-8893-4483-A136-F53660C32423}</UpgradeCode>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" />
8 + </ItemGroup>
9 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/PackageAv1/PackageAv1.wixproj new
+4
@@ -0,0 +1,4 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="PackageA.props" />
4 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/PackageAv2/PackageAv2.wixproj new
+7
@@ -0,0 +1,7 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="..\PackageAv1\PackageA.props" />
4 + <PropertyGroup>
5 + <Version>2.0.0.0</Version>
6 + </PropertyGroup>
7 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/PackageCv1/PackageC.props new
+9
@@ -0,0 +1,9 @@
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 +<Project>
3 + <PropertyGroup>
4 + <UpgradeCode>{DF1C1C42-F5B9-4167-914B-1AF97E829C48}</UpgradeCode>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <Compile Include="..\..\Templates\PackagePerUser.wxs" Link="PackagePerUser.wxs" />
8 + </ItemGroup>
9 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/PackageCv1/PackageCv1.wixproj new
+4
@@ -0,0 +1,4 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="PackageC.props" />
4 +</Project>
\ No newline at end of file
src/TestData/ForwardCompatibleBundleTests/PackageCv2/PackageCv2.wixproj new
+7
@@ -0,0 +1,7 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="..\PackageCv1\PackageC.props" />
4 + <PropertyGroup>
5 + <Version>2.0.0.0</Version>
6 + </PropertyGroup>
7 +</Project>
\ No newline at end of file
src/TestData/Templates/PackagePerUser.wxs new
+65
@@ -0,0 +1,65 @@
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 +
4 +
5 +<?ifndef Version?>
6 +<?define Version = 1.0.0.0?>
7 +<?endif?>
8 +
9 +<?ifndef ProductCode?>
10 +<?define ProductCode = *?>
11 +<?endif?>
12 +
13 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
14 + <Package Name="~$(var.TestGroupName) - $(var.PackageName)" Language="1033" Version="$(var.Version)" Manufacturer="Microsoft Corporation" UpgradeCode="$(var.UpgradeCode)" Compressed="yes" ProductCode="$(var.ProductCode)" Scope="perUser">
15 + <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
16 + <?ifndef CabPrefix?>
17 + <MediaTemplate EmbedCab="yes" />
18 + <?else?>
19 + <MediaTemplate CabinetTemplate="{0}$(var.CabPrefix).cab" />
20 + <?endif?>
21 +
22 + <?ifdef SoftwareTag?>
23 + <SoftwareTag Regid="regid.1995-08.com.example" InstallDirectory="LocalAppDataFolder" />
24 + <?endif?>
25 +
26 + <PropertyRef Id="TestVersion" />
27 +
28 + <Feature Id="Complete" Level="1">
29 + <ComponentRef Id="FileComponent" />
30 + <ComponentRef Id="RegistryComponent" />
31 + <?ifdef var.ProductComponents?>
32 + <ComponentGroupRef Id="ProductComponents" />
33 + <?endif?>
34 + </Feature>
35 + </Package>
36 +
37 + <Fragment>
38 + <Directory Id="TARGETDIR" Name="SourceDir">
39 + <Directory Id="LocalAppDataFolder" />
40 + <Directory Id="ProgramFilesFolder">
41 + <Directory Id="WixDir" Name="~Test WiX">
42 + <Directory Id="TestDir" Name="$(var.TestGroupName)">
43 + <Directory Id="INSTALLFOLDER" Name="$(var.PackageName)" />
44 + </Directory>
45 + </Directory>
46 + </Directory>
47 + </Directory>
48 + </Fragment>
49 +
50 + <Fragment>
51 + <Component Id="FileComponent" Directory="INSTALLFOLDER">
52 + <File Source="$(sys.SOURCEFILEPATH)" />
53 + </Component>
54 + </Fragment>
55 +
56 + <Fragment>
57 + <Component Id="RegistryComponent" Directory="INSTALLFOLDER">
58 + <RegistryValue Root="HKCU" Key="Software\WiX\Tests\$(var.TestGroupName)" Name="$(var.PackageName)" Value="!(bind.Property.TestVersion)" Type="string" />
59 + </Component>
60 + </Fragment>
61 +
62 + <Fragment>
63 + <Property Id="TestVersion" Value="$(var.Version)" />
64 + </Fragment>
65 +</Wix>
src/WixTestTools/BundleRegistration.cs
+26
@@ -151,5 +151,31 @@ namespace WixTestTools
151
152 return registration;
153 }
154 +
155 + public static bool TryGetDependencyProviderValue(string providerId, string name, out string value)
156 + {
157 + value = null;
158 +
159 + string key = String.Format(@"Installer\Dependencies\{0}", providerId);
160 + using (RegistryKey providerKey = Registry.ClassesRoot.OpenSubKey(key))
161 + {
162 + if (null == providerKey)
163 + {
164 + return false;
165 + }
166 +
167 + value = providerKey.GetValue(name) as string;
168 + return value != null;
169 + }
170 + }
171 +
172 + public static bool DependencyDependentExists(string providerId, string dependentId)
173 + {
174 + string key = String.Format(@"Installer\Dependencies\{0}\Dependents\{1}", providerId, dependentId);
175 + using (RegistryKey dependentKey = Registry.ClassesRoot.OpenSubKey(key))
176 + {
177 + return null != dependentKey;
178 + }
179 + }
180 }
181 }
src/WixToolsetTest.BurnE2E/ForwardCompatibleBundleTests.cs new
+469
@@ -0,0 +1,469 @@
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 + [Fact]
21 + public void CanTrack1ForwardCompatibleDependentThroughMajorUpgrade()
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 packageAv2 = this.CreatePackageInstaller("PackageAv2");
29 + var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
30 + var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
31 +
32 + packageAv1.VerifyInstalled(false);
33 + packageAv2.VerifyInstalled(false);
34 +
35 + // Install the v1 bundle with a parent.
36 + bundleAv1.Install(arguments: parentSwitch);
37 + bundleAv1.VerifyRegisteredAndInPackageCache();
38 +
39 + packageAv1.VerifyInstalled(true);
40 + packageAv2.VerifyInstalled(false);
41 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
42 + Assert.Equal(V100, actualProviderVersion);
43 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
44 +
45 + // Upgrade with the v2 bundle.
46 + bundleAv2.Install();
47 + bundleAv2.VerifyRegisteredAndInPackageCache();
48 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
49 +
50 + packageAv1.VerifyInstalled(false);
51 + packageAv2.VerifyInstalled(true);
52 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
53 + Assert.Equal(V200, actualProviderVersion);
54 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
55 +
56 + // Uninstall the v2 bundle and nothing should happen because there is still a parent.
57 + bundleAv2.Uninstall();
58 + bundleAv2.VerifyRegisteredAndInPackageCache();
59 +
60 + packageAv1.VerifyInstalled(false);
61 + packageAv2.VerifyInstalled(true);
62 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
63 + Assert.Equal(V200, actualProviderVersion);
64 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
65 +
66 + // Uninstall the v1 bundle with passthrough and all should be removed.
67 + bundleAv1.Uninstall(arguments: parentSwitch);
68 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
69 + bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();
70 +
71 + packageAv1.VerifyInstalled(false);
72 + packageAv2.VerifyInstalled(false);
73 + Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
74 + }
75 +
76 + [Fact]
77 + public void CanTrack1ForwardCompatibleDependentThroughMajorUpgradeWithParentNone()
78 + {
79 + string providerId = BundleAProviderId;
80 + string parent = "~BundleAv1";
81 + string parentSwitch = String.Concat("-parent ", parent);
82 +
83 + var packageAv1 = this.CreatePackageInstaller("PackageAv1");
84 + var packageAv2 = this.CreatePackageInstaller("PackageAv2");
85 + var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
86 + var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
87 +
88 + packageAv1.VerifyInstalled(false);
89 + packageAv2.VerifyInstalled(false);
90 +
91 + // Install the v1 bundle with a parent.
92 + bundleAv1.Install(arguments: parentSwitch);
93 + bundleAv1.VerifyRegisteredAndInPackageCache();
94 +
95 + packageAv1.VerifyInstalled(true);
96 + packageAv2.VerifyInstalled(false);
97 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
98 + Assert.Equal(V100, actualProviderVersion);
99 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
100 +
101 + // Upgrade with the v2 bundle but prevent self parent being registered.
102 + bundleAv2.Install(arguments: "-parent:none");
103 + bundleAv2.VerifyRegisteredAndInPackageCache();
104 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
105 +
106 + packageAv1.VerifyInstalled(false);
107 + packageAv2.VerifyInstalled(true);
108 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
109 + Assert.Equal(V200, actualProviderVersion);
110 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
111 +
112 + // Uninstall the v1 bundle with passthrough and all should be removed.
113 + bundleAv1.Uninstall(arguments: parentSwitch);
114 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
115 + bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();
116 +
117 + packageAv1.VerifyInstalled(false);
118 + packageAv2.VerifyInstalled(false);
119 + Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
120 + }
121 +
122 + [Fact]
123 + public void CanTrack2ForwardCompatibleDependentsThroughMajorUpgrade()
124 + {
125 + string providerId = BundleAProviderId;
126 + string parent = "~BundleAv1";
127 + string parent2 = "~BundleAv1_Parent2";
128 + string parentSwitch = String.Concat("-parent ", parent);
129 + string parent2Switch = String.Concat("-parent ", parent2);
130 +
131 + var packageAv1 = this.CreatePackageInstaller("PackageAv1");
132 + var packageAv2 = this.CreatePackageInstaller("PackageAv2");
133 + var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
134 + var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
135 +
136 + packageAv1.VerifyInstalled(false);
137 + packageAv2.VerifyInstalled(false);
138 +
139 + // Install the v1 bundle with a parent.
140 + bundleAv1.Install(arguments: parentSwitch);
141 + bundleAv1.VerifyRegisteredAndInPackageCache();
142 +
143 + packageAv1.VerifyInstalled(true);
144 + packageAv2.VerifyInstalled(false);
145 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
146 + Assert.Equal(V100, actualProviderVersion);
147 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
148 +
149 + // Install the v1 bundle with a second parent.
150 + bundleAv1.Install(arguments: parent2Switch);
151 + bundleAv1.VerifyRegisteredAndInPackageCache();
152 +
153 + packageAv1.VerifyInstalled(true);
154 + packageAv2.VerifyInstalled(false);
155 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
156 + Assert.Equal(V100, actualProviderVersion);
157 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
158 +
159 + // Upgrade with the v2 bundle.
160 + bundleAv2.Install();
161 + bundleAv2.VerifyRegisteredAndInPackageCache();
162 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
163 +
164 + packageAv1.VerifyInstalled(false);
165 + packageAv2.VerifyInstalled(true);
166 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
167 + Assert.Equal(V200, actualProviderVersion);
168 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
169 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
170 +
171 + // Uninstall the v2 bundle and nothing should happen because there is still a parent.
172 + bundleAv2.Uninstall();
173 + bundleAv2.VerifyRegisteredAndInPackageCache();
174 +
175 + packageAv1.VerifyInstalled(false);
176 + packageAv2.VerifyInstalled(true);
177 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
178 + Assert.Equal(V200, actualProviderVersion);
179 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
180 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
181 +
182 + // Uninstall one parent of the v1 bundle and nothing should happen because there is still a parent.
183 + bundleAv1.Uninstall(arguments: parentSwitch);
184 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
185 + bundleAv2.VerifyRegisteredAndInPackageCache();
186 +
187 + packageAv1.VerifyInstalled(false);
188 + packageAv2.VerifyInstalled(true);
189 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
190 + Assert.Equal(V200, actualProviderVersion);
191 + Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent));
192 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
193 +
194 + // Uninstall the v1 bundle with passthrough with second parent and all should be removed.
195 + bundleAv1.Uninstall(arguments: parent2Switch);
196 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
197 + bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();
198 +
199 + packageAv1.VerifyInstalled(false);
200 + packageAv2.VerifyInstalled(false);
201 + Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
202 + }
203 +
204 + [Fact]
205 + public void CanTrack2ForwardCompatibleDependentsThroughMajorUpgradePerUser()
206 + {
207 + string providerId = BundleCProviderId;
208 + string parent = "~BundleCv1";
209 + string parent2 = "~BundleCv1_Parent2";
210 + string parentSwitch = String.Concat("-parent ", parent);
211 + string parent2Switch = String.Concat("-parent ", parent2);
212 +
213 + var packageCv1 = this.CreatePackageInstaller("PackageCv1");
214 + var packageCv2 = this.CreatePackageInstaller("PackageCv2");
215 + var bundleCv1 = this.CreateBundleInstaller("BundleCv1");
216 + var bundleCv2 = this.CreateBundleInstaller("BundleCv2");
217 +
218 + packageCv1.VerifyInstalled(false);
219 + packageCv2.VerifyInstalled(false);
220 +
221 + // Install the v1 bundle with a parent.
222 + bundleCv1.Install(arguments: parentSwitch);
223 + bundleCv1.VerifyRegisteredAndInPackageCache();
224 +
225 + packageCv1.VerifyInstalled(true);
226 + packageCv2.VerifyInstalled(false);
227 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
228 + Assert.Equal(V100, actualProviderVersion);
229 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
230 +
231 + // Install the v1 bundle with a second parent.
232 + bundleCv1.Install(arguments: parent2Switch);
233 + bundleCv1.VerifyRegisteredAndInPackageCache();
234 +
235 + packageCv1.VerifyInstalled(true);
236 + packageCv2.VerifyInstalled(false);
237 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
238 + Assert.Equal(V100, actualProviderVersion);
239 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
240 +
241 + // Upgrade with the v2 bundle.
242 + bundleCv2.Install();
243 + bundleCv2.VerifyRegisteredAndInPackageCache();
244 + bundleCv1.VerifyUnregisteredAndRemovedFromPackageCache();
245 +
246 + packageCv1.VerifyInstalled(false);
247 + packageCv2.VerifyInstalled(true);
248 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
249 + Assert.Equal(V200, actualProviderVersion);
250 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
251 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
252 +
253 + // Uninstall the v2 bundle and nothing should happen because there is still a parent.
254 + bundleCv2.Uninstall();
255 + bundleCv2.VerifyRegisteredAndInPackageCache();
256 +
257 + packageCv1.VerifyInstalled(false);
258 + packageCv2.VerifyInstalled(true);
259 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
260 + Assert.Equal(V200, actualProviderVersion);
261 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
262 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
263 +
264 + // Uninstall one parent of the v1 bundle and nothing should happen because there is still a parent.
265 + bundleCv1.Uninstall(arguments: parentSwitch);
266 + bundleCv1.VerifyUnregisteredAndRemovedFromPackageCache();
267 + bundleCv2.VerifyRegisteredAndInPackageCache();
268 +
269 + packageCv1.VerifyInstalled(false);
270 + packageCv2.VerifyInstalled(true);
271 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
272 + Assert.Equal(V200, actualProviderVersion);
273 + Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent));
274 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
275 +
276 + // Uninstall the v1 bundle with passthrough with second parent and all should be removed.
277 + bundleCv1.Uninstall(arguments: parent2Switch);
278 + bundleCv1.VerifyUnregisteredAndRemovedFromPackageCache();
279 + bundleCv2.VerifyUnregisteredAndRemovedFromPackageCache();
280 +
281 + packageCv1.VerifyInstalled(false);
282 + packageCv2.VerifyInstalled(false);
283 + Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
284 + }
285 +
286 + [Fact]
287 + public void CanTrack2ForwardCompatibleDependentsThroughMajorUpgradeWithParent()
288 + {
289 + string providerId = BundleAProviderId;
290 + string parent = "~BundleAv1";
291 + string parent2 = "~BundleAv1_Parent2";
292 + string parent3 = "~BundleAv1_Parent3";
293 + string parentSwitch = String.Concat("-parent ", parent);
294 + string parent2Switch = String.Concat("-parent ", parent2);
295 + string parent3Switch = String.Concat("-parent ", parent3);
296 +
297 + var packageAv1 = this.CreatePackageInstaller("PackageAv1");
298 + var packageAv2 = this.CreatePackageInstaller("PackageAv2");
299 + var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
300 + var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
301 +
302 + packageAv1.VerifyInstalled(false);
303 + packageAv2.VerifyInstalled(false);
304 +
305 + // Install the v1 bundle with a parent.
306 + bundleAv1.Install(arguments: parentSwitch);
307 + bundleAv1.VerifyRegisteredAndInPackageCache();
308 +
309 + packageAv1.VerifyInstalled(true);
310 + packageAv2.VerifyInstalled(false);
311 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
312 + Assert.Equal(V100, actualProviderVersion);
313 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
314 +
315 + // Install the v1 bundle with a second parent.
316 + bundleAv1.Install(arguments: parent2Switch);
317 + bundleAv1.VerifyRegisteredAndInPackageCache();
318 +
319 + packageAv1.VerifyInstalled(true);
320 + packageAv2.VerifyInstalled(false);
321 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
322 + Assert.Equal(V100, actualProviderVersion);
323 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
324 +
325 + // Upgrade with the v2 bundle.
326 + bundleAv2.Install(arguments: parent3Switch);
327 + bundleAv2.VerifyRegisteredAndInPackageCache();
328 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
329 +
330 + packageAv1.VerifyInstalled(false);
331 + packageAv2.VerifyInstalled(true);
332 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
333 + Assert.Equal(V200, actualProviderVersion);
334 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
335 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
336 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent3));
337 +
338 + // Uninstall the v2 bundle and nothing should happen because there is still a parent.
339 + bundleAv2.Uninstall(arguments: parent3Switch);
340 + bundleAv2.VerifyRegisteredAndInPackageCache();
341 +
342 + packageAv1.VerifyInstalled(false);
343 + packageAv2.VerifyInstalled(true);
344 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
345 + Assert.Equal(V200, actualProviderVersion);
346 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
347 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
348 + Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent3));
349 +
350 + // Uninstall one parent of the v1 bundle and nothing should happen because there is still a parent.
351 + bundleAv1.Uninstall(arguments: parentSwitch);
352 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
353 + bundleAv2.VerifyRegisteredAndInPackageCache();
354 +
355 + packageAv1.VerifyInstalled(false);
356 + packageAv2.VerifyInstalled(true);
357 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
358 + Assert.Equal(V200, actualProviderVersion);
359 + Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent));
360 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent2));
361 +
362 + // Uninstall the v1 bundle with passthrough with second parent and all should be removed.
363 + bundleAv1.Uninstall(arguments: parent2Switch);
364 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
365 + bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();
366 +
367 + packageAv1.VerifyInstalled(false);
368 + packageAv2.VerifyInstalled(false);
369 + Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
370 + }
371 +
372 + [Fact]
373 + public void CanUninstallForwardCompatibleWithBundlesUninstalledInFifoOrder()
374 + {
375 + string providerId = BundleAProviderId;
376 + string parent = "~BundleAv1";
377 + string parentSwitch = String.Concat("-parent ", parent);
378 +
379 + var packageAv1 = this.CreatePackageInstaller("PackageAv1");
380 + var packageAv2 = this.CreatePackageInstaller("PackageAv2");
381 + var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
382 + var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
383 +
384 + packageAv1.VerifyInstalled(false);
385 + packageAv2.VerifyInstalled(false);
386 +
387 + bundleAv2.Install();
388 + bundleAv2.VerifyRegisteredAndInPackageCache();
389 +
390 + packageAv1.VerifyInstalled(false);
391 + packageAv2.VerifyInstalled(true);
392 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
393 + Assert.Equal(V200, actualProviderVersion);
394 +
395 + // Install the v1 bundle with a parent which should passthrough to v2.
396 + bundleAv1.Install(arguments: parentSwitch);
397 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
398 +
399 + packageAv1.VerifyInstalled(false);
400 + packageAv2.VerifyInstalled(true);
401 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
402 +
403 + bundleAv2.Uninstall();
404 + bundleAv2.VerifyRegisteredAndInPackageCache();
405 +
406 + packageAv1.VerifyInstalled(false);
407 + packageAv2.VerifyInstalled(true);
408 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
409 +
410 + // Uninstall the v1 bundle with passthrough and all should be removed.
411 + bundleAv1.Uninstall(arguments: parentSwitch);
412 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
413 + bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();
414 +
415 + packageAv1.VerifyInstalled(false);
416 + packageAv2.VerifyInstalled(false);
417 + Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
418 + }
419 +
420 + [Fact]
421 + public void CanUninstallForwardCompatibleWithBundlesUninstalledInReverseOrder()
422 + {
423 + string providerId = BundleAProviderId;
424 + string parent = "~BundleAv1";
425 + string parentSwitch = String.Concat("-parent ", parent);
426 +
427 + var packageAv1 = this.CreatePackageInstaller("PackageAv1");
428 + var packageAv2 = this.CreatePackageInstaller("PackageAv2");
429 + var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
430 + var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
431 +
432 + packageAv1.VerifyInstalled(false);
433 + packageAv2.VerifyInstalled(false);
434 +
435 + bundleAv2.Install();
436 + bundleAv2.VerifyRegisteredAndInPackageCache();
437 +
438 + packageAv1.VerifyInstalled(false);
439 + packageAv2.VerifyInstalled(true);
440 + Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion));
441 + Assert.Equal(V200, actualProviderVersion);
442 +
443 + // Install the v1 bundle with a parent which should passthrough to v2.
444 + bundleAv1.Install(arguments: parentSwitch);
445 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
446 +
447 + packageAv1.VerifyInstalled(false);
448 + packageAv2.VerifyInstalled(true);
449 + Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent));
450 +
451 + // Uninstall the v1 bundle with the same parent which should passthrough to v2 and remove parent.
452 + bundleAv1.Uninstall(arguments: parentSwitch);
453 + bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
454 + bundleAv2.VerifyRegisteredAndInPackageCache();
455 +
456 + packageAv1.VerifyInstalled(false);
457 + packageAv2.VerifyInstalled(true);
458 + Assert.False(BundleRegistration.DependencyDependentExists(providerId, parent));
459 +
460 + // Uninstall the v2 bundle and all should be removed.
461 + bundleAv2.Uninstall();
462 + bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache();
463 +
464 + packageAv1.VerifyInstalled(false);
465 + packageAv2.VerifyInstalled(false);
466 + Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion));
467 + }
468 + }
469 +}