diff options
Diffstat (limited to 'src/test/burn/WixToolsetTest.BurnE2E/FeatureTests.cs')
-rw-r--r-- | src/test/burn/WixToolsetTest.BurnE2E/FeatureTests.cs | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/FeatureTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/FeatureTests.cs new file mode 100644 index 00000000..b3d0dfe1 --- /dev/null +++ b/src/test/burn/WixToolsetTest.BurnE2E/FeatureTests.cs | |||
@@ -0,0 +1,124 @@ | |||
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 WixToolset.Mba.Core; | ||
9 | using Xunit; | ||
10 | using Xunit.Abstractions; | ||
11 | |||
12 | public class FeatureTests : BurnE2ETests | ||
13 | { | ||
14 | public FeatureTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } | ||
15 | |||
16 | [RuntimeFact] | ||
17 | public void CanControlFeatureSelectionDuringInstallAndModify() | ||
18 | { | ||
19 | var packageA = this.CreatePackageInstaller("PackageAv1"); | ||
20 | var bundleA = this.CreateBundleInstaller("BundleAv1"); | ||
21 | var testBAController = this.CreateTestBAController(); | ||
22 | |||
23 | // Install the bundle without the optional feature present | ||
24 | testBAController.SetPackageFeatureState("PackageA", "Complete", FeatureState.Local); | ||
25 | testBAController.SetPackageFeatureState("PackageA", "Test", FeatureState.Absent); | ||
26 | bundleA.Install(); | ||
27 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
28 | |||
29 | string packageSourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); | ||
30 | Assert.False(File.Exists(packageSourceCodeInstalled), String.Concat("Should not have found Package A payload installed at: ", packageSourceCodeInstalled)); | ||
31 | packageA.VerifyTestRegistryValue("PackageA", "1.0.0.0"); | ||
32 | |||
33 | // Now turn on the feature. | ||
34 | testBAController.SetPackageFeatureState("PackageA", "Test", FeatureState.Local); | ||
35 | |||
36 | bundleA.Modify(); | ||
37 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
38 | Assert.True(File.Exists(packageSourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageSourceCodeInstalled)); | ||
39 | |||
40 | // Turn the feature back off. | ||
41 | testBAController.SetPackageFeatureState("PackageA", "Test", FeatureState.Absent); | ||
42 | bundleA.Modify(); | ||
43 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
44 | Assert.False(File.Exists(packageSourceCodeInstalled), String.Concat("Should have removed Package A payload from: ", packageSourceCodeInstalled)); | ||
45 | |||
46 | // Uninstall everything. | ||
47 | testBAController.ResetPackageStates("PackageA"); | ||
48 | bundleA.Uninstall(); | ||
49 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
50 | Assert.False(File.Exists(packageSourceCodeInstalled), String.Concat("Package A payload should have been removed by uninstall from: ", packageSourceCodeInstalled)); | ||
51 | packageA.VerifyTestRegistryRootDeleted(); | ||
52 | } | ||
53 | |||
54 | [RuntimeFact] | ||
55 | public void CanControlFeatureSelectionDuringRepair() | ||
56 | { | ||
57 | var packageA = this.CreatePackageInstaller("PackageAv1"); | ||
58 | var bundleA = this.CreateBundleInstaller("BundleAv1"); | ||
59 | var testBAController = this.CreateTestBAController(); | ||
60 | |||
61 | // Install the bundle with the optional feature present | ||
62 | testBAController.SetPackageFeatureState("PackageA", "Complete", FeatureState.Local); | ||
63 | testBAController.SetPackageFeatureState("PackageA", "Test", FeatureState.Local); | ||
64 | bundleA.Install(); | ||
65 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
66 | |||
67 | string packageSourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); | ||
68 | string packageNotKeyPathFile = packageA.GetInstalledFilePath("notkeypath.file"); | ||
69 | |||
70 | Assert.True(File.Exists(packageSourceCodeInstalled), String.Concat("Should have found Package A keyfile installed at: ", packageSourceCodeInstalled)); | ||
71 | Assert.True(File.Exists(packageNotKeyPathFile), String.Concat("Should have found Package A non-keyfile installed at: ", packageNotKeyPathFile)); | ||
72 | |||
73 | // Delete the non-keypath source file. | ||
74 | File.Delete(packageNotKeyPathFile); | ||
75 | |||
76 | // Now repair without repairing the feature to verify the non-keyfile doesn't come back. | ||
77 | testBAController.SetPackageFeatureState("PackageA", "Test", FeatureState.Unknown); | ||
78 | bundleA.Repair(); | ||
79 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
80 | Assert.True(File.Exists(packageSourceCodeInstalled), String.Concat("Should have found Package A keyfile installed at: ", packageSourceCodeInstalled)); | ||
81 | Assert.False(File.Exists(packageNotKeyPathFile), String.Concat("Should have not found Package A non-keyfile installed at: ", packageNotKeyPathFile)); | ||
82 | |||
83 | // Now repair and include the feature this time. | ||
84 | testBAController.SetPackageFeatureState("PackageA", "Test", FeatureState.Local); | ||
85 | bundleA.Repair(); | ||
86 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
87 | Assert.True(File.Exists(packageSourceCodeInstalled), String.Concat("Should have found Package A keyfile installed at: ", packageSourceCodeInstalled)); | ||
88 | Assert.True(File.Exists(packageNotKeyPathFile), String.Concat("Should have repaired Package A non-keyfile installed at: ", packageNotKeyPathFile)); | ||
89 | |||
90 | // Uninstall everything. | ||
91 | testBAController.ResetPackageStates("PackageA"); | ||
92 | bundleA.Uninstall(); | ||
93 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
94 | Assert.False(File.Exists(packageSourceCodeInstalled), String.Concat("Package A payload should have been removed by uninstall from: ", packageSourceCodeInstalled)); | ||
95 | packageA.VerifyTestRegistryRootDeleted(); | ||
96 | } | ||
97 | |||
98 | [RuntimeFact] | ||
99 | public void CanControlFeatureSelectionDuringMinorUpgrade() | ||
100 | { | ||
101 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); | ||
102 | var packageAv1_0_1 = this.CreatePackageInstaller("PackageAv1_0_1"); | ||
103 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); | ||
104 | var bundleAv1_0_1 = this.CreateBundleInstaller("BundleAv1_0_1"); | ||
105 | var testBAController = this.CreateTestBAController(); | ||
106 | |||
107 | // Install v1 with the optional feature turned on. | ||
108 | testBAController.SetPackageFeatureState("PackageA", "Complete", FeatureState.Local); | ||
109 | testBAController.SetPackageFeatureState("PackageA", "Test", FeatureState.Local); | ||
110 | bundleAv1.Install(); | ||
111 | bundleAv1.VerifyRegisteredAndInPackageCache(); | ||
112 | |||
113 | packageAv1.VerifyInstalledWithVersion(true); | ||
114 | packageAv1.VerifyTestRegistryValue("PackageA", "1.0.0.0"); | ||
115 | |||
116 | // Install v1.0.1 with the optional feature still turned on. | ||
117 | bundleAv1_0_1.Install(); | ||
118 | bundleAv1_0_1.VerifyRegisteredAndInPackageCache(); | ||
119 | |||
120 | packageAv1_0_1.VerifyInstalledWithVersion(true); | ||
121 | packageAv1_0_1.VerifyTestRegistryValue("PackageA", "1.0.1.0"); | ||
122 | } | ||
123 | } | ||
124 | } | ||