diff options
Diffstat (limited to 'src/WixToolsetTest.BurnE2E/CacheTests.cs')
-rw-r--r-- | src/WixToolsetTest.BurnE2E/CacheTests.cs | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/WixToolsetTest.BurnE2E/CacheTests.cs b/src/WixToolsetTest.BurnE2E/CacheTests.cs new file mode 100644 index 00000000..f62b0874 --- /dev/null +++ b/src/WixToolsetTest.BurnE2E/CacheTests.cs | |||
@@ -0,0 +1,106 @@ | |||
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.Collections.Generic; | ||
6 | using System.IO; | ||
7 | using WixBuildTools.TestSupport; | ||
8 | using WixToolset.Mba.Core; | ||
9 | using Xunit; | ||
10 | using Xunit.Abstractions; | ||
11 | |||
12 | public class CacheTests : BurnE2ETests | ||
13 | { | ||
14 | public CacheTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } | ||
15 | |||
16 | [Fact] | ||
17 | public void CanDownloadPayloadsFromMissingAttachedContainer() | ||
18 | { | ||
19 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
20 | var packageB = this.CreatePackageInstaller("PackageB"); | ||
21 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
22 | var testBAController = this.CreateTestBAController(); | ||
23 | var webServer = this.CreateWebServer(); | ||
24 | |||
25 | webServer.AddFiles(new Dictionary<string, string> | ||
26 | { | ||
27 | { "/BundleA/PackageA.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageA.msi") }, | ||
28 | { "/BundleA/PackageB.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageB.msi") }, | ||
29 | }); | ||
30 | webServer.Start(); | ||
31 | |||
32 | // Don't install PackageB initially so it will be installed when run from the package cache. | ||
33 | testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); | ||
34 | |||
35 | packageA.VerifyInstalled(false); | ||
36 | packageB.VerifyInstalled(false); | ||
37 | |||
38 | // Manually copy bundle to separate directory, install from there, and then delete it | ||
39 | // so that when run from the package cache, it can't find the attached container. | ||
40 | using (var dfs = new DisposableFileSystem()) | ||
41 | { | ||
42 | var tempDirectory = dfs.GetFolder(true); | ||
43 | |||
44 | var bundleAFileInfo = new FileInfo(bundleA.Bundle); | ||
45 | var bundleACopiedPath = Path.Combine(tempDirectory, bundleAFileInfo.Name); | ||
46 | bundleAFileInfo.CopyTo(bundleACopiedPath); | ||
47 | |||
48 | bundleA.Install(bundleACopiedPath); | ||
49 | } | ||
50 | |||
51 | var bundlePackageCachePath = bundleA.VerifyRegisteredAndInPackageCache(); | ||
52 | |||
53 | packageA.VerifyInstalled(true); | ||
54 | packageB.VerifyInstalled(false); | ||
55 | |||
56 | testBAController.SetPackageRequestedState("PackageB", RequestState.Present); | ||
57 | |||
58 | bundleA.Modify(bundlePackageCachePath); | ||
59 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
60 | |||
61 | packageA.VerifyInstalled(true); | ||
62 | packageB.VerifyInstalled(true); | ||
63 | } | ||
64 | |||
65 | [Fact] | ||
66 | public void CanFindAttachedContainerFromRenamedBundle() | ||
67 | { | ||
68 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
69 | var packageB = this.CreatePackageInstaller("PackageB"); | ||
70 | var bundleB = this.CreateBundleInstaller("BundleB"); | ||
71 | var testBAController = this.CreateTestBAController(); | ||
72 | |||
73 | // Don't install PackageB initially so it will be installed when run from the package cache. | ||
74 | testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); | ||
75 | |||
76 | packageA.VerifyInstalled(false); | ||
77 | packageB.VerifyInstalled(false); | ||
78 | |||
79 | // Manually copy bundle to separate directory with new name and install from there | ||
80 | // so that when run from the package cache, it has to get the attached container from the renamed bundle. | ||
81 | using (var dfs = new DisposableFileSystem()) | ||
82 | { | ||
83 | var tempDirectory = dfs.GetFolder(true); | ||
84 | |||
85 | var bundleBFileInfo = new FileInfo(bundleB.Bundle); | ||
86 | var bundleBCopiedPath = Path.Combine(tempDirectory, "RenamedBundle.exe"); | ||
87 | bundleBFileInfo.CopyTo(bundleBCopiedPath); | ||
88 | |||
89 | bundleB.Install(bundleBCopiedPath); | ||
90 | |||
91 | var bundlePackageCachePath = bundleB.VerifyRegisteredAndInPackageCache(); | ||
92 | |||
93 | packageA.VerifyInstalled(true); | ||
94 | packageB.VerifyInstalled(false); | ||
95 | |||
96 | testBAController.SetPackageRequestedState("PackageB", RequestState.Present); | ||
97 | |||
98 | bundleB.Modify(bundlePackageCachePath); | ||
99 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
100 | |||
101 | packageA.VerifyInstalled(true); | ||
102 | packageB.VerifyInstalled(true); | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | } | ||