| 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; |
| 6 | using System.Collections.Generic; |
| 7 | using WixTestTools; |
| 8 | using Xunit; |
| 9 | using Xunit.Abstractions; |
| 10 | |
| 11 | [Collection("BurnE2E")] |
| 12 | public abstract class BurnE2ETests : WixTestBase, IDisposable |
| 13 | { |
| 14 | protected BurnE2ETests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) |
| 15 | { |
| 16 | // https://github.com/microsoft/vstest/issues/3586 |
| 17 | Environment.SetEnvironmentVariable("DOTNET_ROOT", null); |
| 18 | } |
| 19 | |
| 20 | private Stack<IDisposable> Installers { get; } = new Stack<IDisposable>(); |
| 21 | |
| 22 | protected bool SupportAddonAndPatchRelatedBundles => |
| 23 | #if SUPPORT_ADDON_AND_PATCH_RELATED_BUNDLES |
| 24 | true; |
| 25 | #else |
| 26 | false; |
| 27 | #endif |
| 28 | |
| 29 | protected void AddBundleInstaller(BundleInstaller installer) |
| 30 | { |
| 31 | this.Installers.Push(installer); |
| 32 | } |
| 33 | |
| 34 | protected ArpEntryInstaller CreateArpEntryInstaller(string id, bool perMachine = true, bool x64 = false) |
| 35 | { |
| 36 | var installer = new ArpEntryInstaller(this.TestContext, id, perMachine, x64); |
| 37 | this.Installers.Push(installer); |
| 38 | return installer; |
| 39 | } |
| 40 | |
| 41 | protected ArpEntryInstaller CreateArpEntryInstaller(BundleInstaller bundleInstaller, string packageId) |
| 42 | { |
| 43 | if (!bundleInstaller.TryGetArpEntryExePackageConfiguration(packageId, out var arpId, out _, out var arpWin64, out var perMachine)) |
| 44 | { |
| 45 | return null; |
| 46 | } |
| 47 | |
| 48 | return this.CreateArpEntryInstaller(arpId, perMachine, arpWin64); |
| 49 | } |
| 50 | |
| 51 | protected BundleInstaller CreateBundleInstaller(string name) |
| 52 | { |
| 53 | var installer = new BundleInstaller(this.TestContext, name); |
| 54 | this.Installers.Push(installer); |
| 55 | return installer; |
| 56 | } |
| 57 | |
| 58 | protected PackageInstaller CreatePackageInstaller(string filename) |
| 59 | { |
| 60 | var installer = new PackageInstaller(this.TestContext, filename); |
| 61 | this.Installers.Push(installer); |
| 62 | return installer; |
| 63 | } |
| 64 | |
| 65 | protected TestBAController CreateTestBAController() |
| 66 | { |
| 67 | var controller = new TestBAController(this.TestContext); |
| 68 | this.Installers.Push(controller); |
| 69 | return controller; |
| 70 | } |
| 71 | |
| 72 | protected IWebServer CreateWebServer() |
| 73 | { |
| 74 | var webServer = new CoreOwinWebServer(); |
| 75 | this.Installers.Push(webServer); |
| 76 | return webServer; |
| 77 | } |
| 78 | |
| 79 | public void Dispose() |
| 80 | { |
| 81 | while (this.Installers.TryPop(out var installer)) |
| 82 | { |
| 83 | try |
| 84 | { |
| 85 | installer.Dispose(); |
| 86 | } |
| 87 | catch { } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | [CollectionDefinition("BurnE2E", DisableParallelization = true)] |
| 93 | public class BurnE2ECollectionDefinition |
| 94 | { |
| 95 | } |
| 96 | } |