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