aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/WixToolsetTest.BurnE2E/BurnE2ETests.cs
blob: 5caedacb629323c6a602562c9d69d97b057a2d75 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// 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.Collections.Generic;
    using WixTestTools;
    using Xunit;
    using Xunit.Abstractions;

    [Collection("BurnE2E")]
    public abstract class BurnE2ETests : WixTestBase, IDisposable
    {
        protected BurnE2ETests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
        {
            // https://github.com/microsoft/vstest/issues/3586
            Environment.SetEnvironmentVariable("DOTNET_ROOT", null);
        }

        private Stack<IDisposable> Installers { get; } = new Stack<IDisposable>();

        protected bool SupportAddonAndPatchRelatedBundles =>
#if SUPPORT_ADDON_AND_PATCH_RELATED_BUNDLES
            true;
#else
            false;
#endif

        protected void AddBundleInstaller(BundleInstaller installer)
        {
            this.Installers.Push(installer);
        }

        protected ArpEntryInstaller CreateArpEntryInstaller(string id, bool perMachine = true, bool x64 = false)
        {
            var installer = new ArpEntryInstaller(this.TestContext, id, perMachine, x64);
            this.Installers.Push(installer);
            return installer;
        }

        protected ArpEntryInstaller CreateArpEntryInstaller(BundleInstaller bundleInstaller, string packageId)
        {
            if (!bundleInstaller.TryGetArpEntryExePackageConfiguration(packageId, out var arpId, out _, out var arpWin64, out var perMachine))
            {
                return null;
            }

            return this.CreateArpEntryInstaller(arpId, perMachine, arpWin64);
        }

        protected BundleInstaller CreateBundleInstaller(string name)
        {
            var installer = new BundleInstaller(this.TestContext, name);
            this.Installers.Push(installer);
            return installer;
        }

        protected PackageInstaller CreatePackageInstaller(string filename)
        {
            var installer = new PackageInstaller(this.TestContext, filename);
            this.Installers.Push(installer);
            return installer;
        }

        protected TestBAController CreateTestBAController()
        {
            var controller = new TestBAController(this.TestContext);
            this.Installers.Push(controller);
            return controller;
        }

        protected IWebServer CreateWebServer()
        {
            var webServer = new CoreOwinWebServer();
            this.Installers.Push(webServer);
            return webServer;
        }

        public void Dispose()
        {
            while (this.Installers.TryPop(out var installer))
            {
                try
                {
                    installer.Dispose();
                }
                catch { }
            }
        }
    }

    [CollectionDefinition("BurnE2E", DisableParallelization = true)]
    public class BurnE2ECollectionDefinition
    {
    }
}