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