wabbajack/Wabbajack.Test/ACompilerTest.cs

66 lines
2.0 KiB
C#
Raw Normal View History

using System;
2019-12-07 02:54:27 +00:00
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common;
using Wabbajack.Lib;
2019-12-07 17:39:22 +00:00
using Wabbajack.Lib.LibCefHelpers;
namespace Wabbajack.Test
{
public abstract class ACompilerTest
{
public TestContext TestContext { get; set; }
protected TestUtils utils { get; set; }
[TestInitialize]
2019-12-18 03:18:33 +00:00
public async Task TestInitialize()
{
await Helpers.Initialize();
Consts.TestMode = true;
utils = new TestUtils();
2019-11-16 22:02:36 +00:00
utils.Game = Game.SkyrimSpecialEdition;
2019-12-04 04:12:08 +00:00
Utils.LogMessages.Subscribe(f => TestContext.WriteLine(f.ShortDescription));
}
[TestCleanup]
public void TestCleanup()
{
utils.Dispose();
}
2019-12-07 02:54:27 +00:00
protected async Task<MO2Compiler> ConfigureAndRunCompiler(string profile)
{
var compiler = new MO2Compiler(
mo2Folder: utils.MO2Folder,
mo2Profile: profile,
outputFile: profile + ExtensionManager.Extension);
compiler.ShowReportWhenFinished = false;
2019-12-07 02:54:27 +00:00
Assert.IsTrue(await compiler.Begin());
return compiler;
}
2019-12-07 02:54:27 +00:00
protected async Task<ModList> CompileAndInstall(string profile)
2019-11-02 15:38:03 +00:00
{
2019-12-07 02:54:27 +00:00
var compiler = await ConfigureAndRunCompiler(profile);
2019-12-22 00:26:51 +00:00
await Install(compiler);
2019-11-02 15:38:03 +00:00
return compiler.ModList;
}
2019-12-22 00:26:51 +00:00
protected async Task Install(MO2Compiler compiler)
2019-11-02 15:38:03 +00:00
{
2019-11-21 15:05:10 +00:00
var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile);
var installer = new MO2Installer(
archive: compiler.ModListOutputFile,
modList: modlist,
outputFolder: utils.InstallFolder,
downloadFolder: utils.DownloadsFolder);
installer.WarnOnOverwrite = false;
2019-11-02 15:38:03 +00:00
installer.GameFolder = utils.GameFolder;
2019-12-22 00:26:51 +00:00
await installer.Begin();
2019-11-02 15:38:03 +00:00
}
}
}