wabbajack/Wabbajack.Test/AVortexCompilerTest.cs

78 lines
2.4 KiB
C#
Raw Normal View History

using System;
using System.IO;
2019-12-07 02:54:27 +00:00
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack.Test
{
public abstract class AVortexCompilerTest
{
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
Game = Game.DarkestDungeon
};
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<VortexCompiler> ConfigureAndRunCompiler()
{
var vortexCompiler = MakeCompiler();
vortexCompiler.DownloadsFolder = utils.DownloadsFolder;
vortexCompiler.StagingFolder = utils.InstallFolder;
Directory.CreateDirectory(utils.InstallFolder);
2019-12-07 02:54:27 +00:00
Assert.IsTrue(await vortexCompiler.Begin());
return vortexCompiler;
}
protected VortexCompiler MakeCompiler()
{
2019-11-16 22:10:13 +00:00
return new VortexCompiler(
game: utils.Game,
gamePath: utils.GameFolder,
vortexFolder: VortexCompiler.TypicalVortexFolder(),
downloadsFolder: VortexCompiler.RetrieveDownloadLocation(utils.Game),
stagingFolder: VortexCompiler.RetrieveStagingLocation(utils.Game),
outputFile: $"test{ExtensionManager.Extension}");
}
2019-12-07 02:54:27 +00:00
protected async Task<ModList> CompileAndInstall()
{
2019-12-07 02:54:27 +00:00
var vortexCompiler = await ConfigureAndRunCompiler();
2019-12-22 00:26:51 +00:00
await Install(vortexCompiler);
return vortexCompiler.ModList;
}
2019-12-22 00:26:51 +00:00
protected async Task Install(VortexCompiler vortexCompiler)
{
2019-11-21 15:05:10 +00:00
var modList = AInstaller.LoadFromFile(vortexCompiler.ModListOutputFile);
var installer = new MO2Installer(
archive: vortexCompiler.ModListOutputFile,
modList: modList,
outputFolder: utils.InstallFolder,
downloadFolder: utils.DownloadsFolder)
{
GameFolder = utils.GameFolder,
};
2019-12-22 00:26:51 +00:00
await installer.Begin();
}
}
}