wabbajack/Wabbajack.Test/ACompilerTest.cs

66 lines
1.9 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]
public void TestInitialize()
{
2019-12-07 17:39:22 +00:00
Helpers.ExtractLibs();
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-11-02 15:38:03 +00:00
Install(compiler);
return compiler.ModList;
}
protected void 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;
installer.Begin().Wait();
2019-11-02 15:38:03 +00:00
}
}
}