using System; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.VisualStudio.TestTools.UnitTesting; using Wabbajack.Common; using Wabbajack.Lib; using Wabbajack.Lib.LibCefHelpers; using Wabbajack.Util; namespace Wabbajack.Test { public abstract class ACompilerTest { public TestContext TestContext { get; set; } protected TestUtils utils { get; set; } [TestInitialize] public async Task TestInitialize() { Helpers.Init(); Consts.TestMode = true; utils = new TestUtils(); utils.Game = Game.SkyrimSpecialEdition; Utils.LogMessages.Subscribe(f => TestContext.WriteLine(f.ShortDescription)); } [TestCleanup] public void TestCleanup() { utils.Dispose(); } protected async Task ConfigureAndRunCompiler(string profile) { var compiler = new MO2Compiler( mo2Folder: utils.MO2Folder, mo2Profile: profile, outputFile: profile + ExtensionManager.Extension); compiler.ShowReportWhenFinished = false; Assert.IsTrue(await compiler.Begin()); return compiler; } protected async Task CompileAndInstall(string profile) { var compiler = await ConfigureAndRunCompiler(profile); await Install(compiler); return compiler.ModList; } protected async Task Install(MO2Compiler compiler) { var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile); var installer = new MO2Installer( archive: compiler.ModListOutputFile, modList: modlist, outputFolder: utils.InstallFolder, downloadFolder: utils.DownloadsFolder, parameters: SystemParametersConstructor.Create()); installer.WarnOnOverwrite = false; installer.GameFolder = utils.GameFolder; await installer.Begin(); } } }