2019-10-31 02:24:42 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Wabbajack.Lib;
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
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-11-05 04:14:31 +00:00
|
|
|
|
Utils.LogMessages.Subscribe(f => TestContext.WriteLine(f));
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCleanup]
|
|
|
|
|
public void TestCleanup()
|
|
|
|
|
{
|
|
|
|
|
utils.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-18 00:17:06 +00:00
|
|
|
|
protected 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-11-17 23:48:32 +00:00
|
|
|
|
Assert.IsTrue(compiler.Begin().Result);
|
2019-10-31 02:24:42 +00:00
|
|
|
|
return compiler;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-02 15:38:03 +00:00
|
|
|
|
protected ModList CompileAndInstall(string profile)
|
|
|
|
|
{
|
|
|
|
|
var compiler = ConfigureAndRunCompiler(profile);
|
|
|
|
|
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-11-18 00:17:06 +00:00
|
|
|
|
var installer = new MO2Installer(compiler.ModListOutputFile, modlist, utils.InstallFolder);
|
2019-11-18 05:21:24 +00:00
|
|
|
|
installer.WarnOnOverwrite = false;
|
2019-11-02 15:38:03 +00:00
|
|
|
|
installer.DownloadFolder = utils.DownloadsFolder;
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|