wabbajack/Wabbajack.Test/ACompilerTest.cs

66 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 Compiler ConfigureAndRunCompiler(string profile)
{
var compiler = MakeCompiler();
compiler.MO2Profile = profile;
compiler.ShowReportWhenFinished = false;
Assert.IsTrue(compiler.Compile());
return compiler;
}
protected Compiler MakeCompiler()
{
var compiler = new Compiler(utils.MO2Folder);
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(Compiler compiler)
{
var modlist = Installer.LoadFromFile(compiler.ModListOutputFile);
var installer = new Installer(compiler.ModListOutputFile, modlist, utils.InstallFolder);
installer.DownloadFolder = utils.DownloadsFolder;
installer.GameFolder = utils.GameFolder;
installer.Install();
}
}
}