wabbajack/Wabbajack.Test/ACompilerTest.cs

63 lines
1.8 KiB
C#
Raw Normal View History

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack.Test
{
public abstract class ACompilerTest
{
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;
Utils.LogMessages.Subscribe(f => TestContext.WriteLine(f));
}
[TestCleanup]
public void TestCleanup()
{
utils.Dispose();
}
protected MO2Compiler ConfigureAndRunCompiler(string profile)
{
var compiler = new MO2Compiler(
mo2Folder: utils.MO2Folder,
mo2Profile: profile,
outputFile: profile + ExtensionManager.Extension);
compiler.ShowReportWhenFinished = false;
Assert.IsTrue(compiler.Begin().Result);
return compiler;
}
2019-11-02 15:38:03 +00:00
protected ModList CompileAndInstall(string profile)
{
var compiler = ConfigureAndRunCompiler(profile);
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
}
}
}