2019-11-12 17:54:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2019-12-07 02:54:27 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-11-12 17:54:48 +00:00
|
|
|
|
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-11-12 17:54:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-12-04 04:12:08 +00:00
|
|
|
|
Utils.LogMessages.Subscribe(f => TestContext.WriteLine(f.ShortDescription));
|
2019-11-12 17:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCleanup]
|
|
|
|
|
public void TestCleanup()
|
|
|
|
|
{
|
|
|
|
|
utils.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-07 02:54:27 +00:00
|
|
|
|
protected async Task<VortexCompiler> ConfigureAndRunCompiler()
|
2019-11-12 17:54:48 +00:00
|
|
|
|
{
|
|
|
|
|
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());
|
2019-11-12 17:54:48 +00:00
|
|
|
|
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),
|
2019-11-24 00:30:51 +00:00
|
|
|
|
stagingFolder: VortexCompiler.RetrieveStagingLocation(utils.Game),
|
|
|
|
|
outputFile: $"test{ExtensionManager.Extension}");
|
2019-11-12 17:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-07 02:54:27 +00:00
|
|
|
|
protected async Task<ModList> CompileAndInstall()
|
2019-11-12 17:54:48 +00:00
|
|
|
|
{
|
2019-12-07 02:54:27 +00:00
|
|
|
|
var vortexCompiler = await ConfigureAndRunCompiler();
|
2019-12-22 00:26:51 +00:00
|
|
|
|
await Install(vortexCompiler);
|
2019-11-12 17:54:48 +00:00
|
|
|
|
return vortexCompiler.ModList;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-22 00:26:51 +00:00
|
|
|
|
protected async Task Install(VortexCompiler vortexCompiler)
|
2019-11-12 17:54:48 +00:00
|
|
|
|
{
|
2019-11-21 15:05:10 +00:00
|
|
|
|
var modList = AInstaller.LoadFromFile(vortexCompiler.ModListOutputFile);
|
2019-12-01 20:22:33 +00:00
|
|
|
|
var installer = new MO2Installer(
|
|
|
|
|
archive: vortexCompiler.ModListOutputFile,
|
|
|
|
|
modList: modList,
|
|
|
|
|
outputFolder: utils.InstallFolder,
|
|
|
|
|
downloadFolder: utils.DownloadsFolder)
|
2019-11-12 17:54:48 +00:00
|
|
|
|
{
|
|
|
|
|
GameFolder = utils.GameFolder,
|
|
|
|
|
};
|
2019-12-22 00:26:51 +00:00
|
|
|
|
await installer.Begin();
|
2019-11-12 17:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|