aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolsetTest.BurnE2E/MsiTransactionTests.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/WixToolsetTest.BurnE2E/MsiTransactionTests.cs111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/WixToolsetTest.BurnE2E/MsiTransactionTests.cs b/src/WixToolsetTest.BurnE2E/MsiTransactionTests.cs
new file mode 100644
index 00000000..3c9261a7
--- /dev/null
+++ b/src/WixToolsetTest.BurnE2E/MsiTransactionTests.cs
@@ -0,0 +1,111 @@
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
3namespace WixToolsetTest.BurnE2E
4{
5 using System;
6 using System.IO;
7 using Xunit;
8 using Xunit.Abstractions;
9
10 public class MsiTransactionTests : BurnE2ETests
11 {
12 public MsiTransactionTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper, "MsiTransaction") { }
13
14 [Fact]
15 public void CanUpgradeBundleWithMsiTransaction()
16 {
17 var packageA = this.CreatePackageInstaller("PackageA");
18 var packageBv1 = this.CreatePackageInstaller("PackageBv1");
19 var packageBv2 = this.CreatePackageInstaller("PackageBv2");
20 var packageCv1 = this.CreatePackageInstaller("PackageCv1");
21 var packageCv2 = this.CreatePackageInstaller("PackageCv2");
22 var packageD = this.CreatePackageInstaller("PackageD");
23
24 var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
25 var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
26
27 var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
28 var packageBv1SourceCodeInstalled = packageBv1.GetInstalledFilePath("Package.wxs");
29 var packageBv2SourceCodeInstalled = packageBv2.GetInstalledFilePath("Package.wxs");
30 var packageCv1SourceCodeInstalled = packageCv1.GetInstalledFilePath("Package.wxs");
31 var packageCv2SourceCodeInstalled = packageCv2.GetInstalledFilePath("Package.wxs");
32 var packageDSourceCodeInstalled = packageD.GetInstalledFilePath("Package.wxs");
33
34 // Source file should *not* be installed
35 Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
36 Assert.False(File.Exists(packageBv1SourceCodeInstalled), $"Package Bv1 payload should not be there on test start: {packageBv1SourceCodeInstalled}");
37 Assert.False(File.Exists(packageBv2SourceCodeInstalled), $"Package Bv2 payload should not be there on test start: {packageBv2SourceCodeInstalled}");
38 Assert.False(File.Exists(packageCv1SourceCodeInstalled), $"Package Cv1 payload should not be there on test start: {packageCv1SourceCodeInstalled}");
39 Assert.False(File.Exists(packageCv2SourceCodeInstalled), $"Package Cv2 payload should not be there on test start: {packageCv2SourceCodeInstalled}");
40 Assert.False(File.Exists(packageDSourceCodeInstalled), $"Package D payload should not be there on test start: {packageDSourceCodeInstalled}");
41
42 bundleAv1.Install();
43
44 // Source file should be installed
45 Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
46 Assert.True(File.Exists(packageBv1SourceCodeInstalled), String.Concat("Should have found Package Bv1 payload installed at: ", packageBv1SourceCodeInstalled));
47 Assert.True(File.Exists(packageCv1SourceCodeInstalled), String.Concat("Should have found Package Cv1 payload installed at: ", packageCv1SourceCodeInstalled));
48
49 bundleAv2.Install();
50
51 // Source file should be upgraded
52 Assert.True(File.Exists(packageDSourceCodeInstalled), String.Concat("Should have found Package D payload installed at: ", packageDSourceCodeInstalled));
53 Assert.True(File.Exists(packageBv2SourceCodeInstalled), String.Concat("Should have found Package Bv2 payload installed at: ", packageBv2SourceCodeInstalled));
54 Assert.True(File.Exists(packageCv2SourceCodeInstalled), String.Concat("Should have found Package Cv2 payload installed at: ", packageCv2SourceCodeInstalled));
55 Assert.False(File.Exists(packageCv1SourceCodeInstalled), String.Concat("Package Cv1 payload should have been removed by upgrade uninstall from: ", packageCv1SourceCodeInstalled));
56 Assert.False(File.Exists(packageBv1SourceCodeInstalled), String.Concat("Package Bv1 payload should have been removed by upgrade uninstall from: ", packageBv1SourceCodeInstalled));
57 Assert.False(File.Exists(packageASourceCodeInstalled), String.Concat("Package A payload should have been removed by upgrade uninstall from: ", packageASourceCodeInstalled));
58
59 // Uninstall everything.
60 bundleAv2.Uninstall();
61
62 // Source file should *not* be installed
63 Assert.False(File.Exists(packageDSourceCodeInstalled), String.Concat("Package D payload should have been removed by uninstall from: ", packageDSourceCodeInstalled));
64 Assert.False(File.Exists(packageBv2SourceCodeInstalled), String.Concat("Package Bv2 payload should have been removed by uninstall from: ", packageBv2SourceCodeInstalled));
65 Assert.False(File.Exists(packageCv2SourceCodeInstalled), String.Concat("Package Cv2 payload should have been removed by uninstall from: ", packageCv2SourceCodeInstalled));
66 }
67
68 /// <summary>
69 /// Installs 2 bundles:
70 /// BundleBv1- installs package Bv1
71 /// BundleBv2- installs packages A, Bv2, F
72 /// package Bv2 performs a major upgrade of package Bv1
73 /// package F fails
74 /// Thus, rolling back the transaction should reinstall package Bv1
75 /// </summary>
76 [Fact]
77 public void CanRelyOnMsiTransactionRollback()
78 {
79 var packageA = this.CreatePackageInstaller("PackageA");
80 var packageBv1 = this.CreatePackageInstaller("PackageBv1");
81 var packageBv2 = this.CreatePackageInstaller("PackageBv2");
82 this.CreatePackageInstaller("PackageF");
83
84 var bundleBv1 = this.CreateBundleInstaller("BundleBv1");
85 var bundleBv2 = this.CreateBundleInstaller("BundleBv2");
86
87 var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
88 var packageBv1SourceCodeInstalled = packageBv1.GetInstalledFilePath("Package.wxs");
89 var packageBv2SourceCodeInstalled = packageBv2.GetInstalledFilePath("Package.wxs");
90
91 // Source file should *not* be installed
92 Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
93 Assert.False(File.Exists(packageBv1SourceCodeInstalled), $"Package Bv1 payload should not be there on test start: {packageBv1SourceCodeInstalled}");
94 Assert.False(File.Exists(packageBv2SourceCodeInstalled), $"Package Bv2 payload should not be there on test start: {packageBv2SourceCodeInstalled}");
95
96 bundleBv1.Install();
97
98 // Source file should be installed
99 Assert.True(File.Exists(packageBv1SourceCodeInstalled), String.Concat("Should have found Package Bv1 payload installed at: ", packageBv1SourceCodeInstalled));
100
101 bundleBv2.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);
102
103 // Source file should be installed
104 Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
105
106 // Previous source file should be installed
107 Assert.True(File.Exists(packageBv1SourceCodeInstalled), String.Concat("Should have found Package Bv1 payload installed at: ", packageBv1SourceCodeInstalled));
108 Assert.False(File.Exists(packageBv2SourceCodeInstalled), String.Concat("Should not have found Package Bv2 payload installed at: ", packageBv2SourceCodeInstalled));
109 }
110 }
111}