summaryrefslogtreecommitdiff
path: root/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs
blob: ec828f89bd950d1b484decddc559dd52bf8e63d5 (plain)
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
// 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;
    using System.IO;
    using WixTestTools;
    using Xunit;
    using Xunit.Abstractions;

    public class PrereqBaTests : BurnE2ETests
    {
        public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }

        /// <summary>
        /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
        /// with an MSI package to represent the prerequisite package.
        /// This verifies that:
        ///   The preqba doesn't infinitely reload itself after failing to load the managed BA.
        ///   The engine automatically uninstalls the bundle since only permanent packages were installed.
        /// </summary>
        [RuntimeFact]
        public void DncPreqBaDetectsInfiniteLoop()
        {
            var packageA = this.CreatePackageInstaller("PackageA");
            this.CreatePackageInstaller("PackageF");

            var bundleA = this.CreateBundleInstaller("BundleA");

            var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");

            // Source file should *not* be installed
            Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");

            bundleA.Install();

            // Part of the test is Install actually completing.

            // Source file should be installed
            Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));

            // No non-permanent packages should have ended up installed or cached so it should have unregistered.
            bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
        }

        /// <summary>
        /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
        /// with an MSI package to represent the prerequisite package.
        /// This verifies that:
        ///   The preqba doesn't infinitely reload itself after failing to load the managed BA.
        ///   The engine automatically uninstalls the bundle since only permanent packages were installed.
        /// </summary>
        [RuntimeFact]
        public void MbaPreqBaDetectsInfiniteLoop()
        {
            var packageB = this.CreatePackageInstaller("PackageB");
            this.CreatePackageInstaller("PackageF");

            var bundleB = this.CreateBundleInstaller("BundleB");

            var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");

            // Source file should *not* be installed
            Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");

            bundleB.Install();

            // Part of the test is Install actually completing.

            // Source file should be installed
            Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));

            // No non-permanent packages should have ended up installed or cached so it should have unregistered.
            bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
        }
    }
}