2019-10-31 02:24:42 +00:00
|
|
|
|
using System;
|
2019-12-07 02:54:27 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Wabbajack.Lib;
|
2019-12-07 17:39:22 +00:00
|
|
|
|
using Wabbajack.Lib.LibCefHelpers;
|
2020-03-26 21:15:44 +00:00
|
|
|
|
using Xunit;
|
|
|
|
|
using Xunit.Abstractions;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Test
|
|
|
|
|
{
|
2020-03-29 20:42:45 +00:00
|
|
|
|
public abstract class ACompilerTest : XunitContextBase, IDisposable
|
2019-10-31 02:24:42 +00:00
|
|
|
|
{
|
2020-03-29 20:42:45 +00:00
|
|
|
|
private IDisposable _unsub;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
protected TestUtils utils { get; set; }
|
|
|
|
|
|
2020-03-29 20:42:45 +00:00
|
|
|
|
public ACompilerTest(ITestOutputHelper helper) : base (helper)
|
2019-10-31 02:24:42 +00:00
|
|
|
|
{
|
2019-12-27 00:41:33 +00:00
|
|
|
|
Helpers.Init();
|
2019-10-31 02:24:42 +00:00
|
|
|
|
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
|
|
|
|
|
2020-03-28 02:54:14 +00:00
|
|
|
|
DateTime startTime = DateTime.Now;
|
2020-03-29 20:42:45 +00:00
|
|
|
|
_unsub = Utils.LogMessages.Subscribe(f => XunitContext.WriteLine($"{DateTime.Now - startTime} - {f.ShortDescription}"));
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-29 20:42:45 +00:00
|
|
|
|
public override void Dispose()
|
2019-10-31 02:24:42 +00:00
|
|
|
|
{
|
2020-04-10 19:33:09 +00:00
|
|
|
|
utils.DisposeAsync().AsTask().Wait();
|
2020-03-29 20:42:45 +00:00
|
|
|
|
_unsub.Dispose();
|
|
|
|
|
base.Dispose();
|
2019-10-31 02:24:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-07 02:54:27 +00:00
|
|
|
|
protected async Task<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,
|
2020-03-26 21:15:44 +00:00
|
|
|
|
outputFile: OutputFile(profile));
|
|
|
|
|
Assert.True(await compiler.Begin());
|
2019-10-31 02:24:42 +00:00
|
|
|
|
return compiler;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-07 02:54:27 +00:00
|
|
|
|
protected async Task<ModList> CompileAndInstall(string profile)
|
2019-11-02 15:38:03 +00:00
|
|
|
|
{
|
2019-12-07 02:54:27 +00:00
|
|
|
|
var compiler = await ConfigureAndRunCompiler(profile);
|
2020-03-28 02:54:14 +00:00
|
|
|
|
Utils.Log("Finished Compiling");
|
2019-12-22 00:26:51 +00:00
|
|
|
|
await Install(compiler);
|
2019-11-02 15:38:03 +00:00
|
|
|
|
return compiler.ModList;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:15:44 +00:00
|
|
|
|
private static AbsolutePath OutputFile(string profile)
|
|
|
|
|
{
|
|
|
|
|
return ((RelativePath)profile).RelativeToEntryPoint().WithExtension(Consts.ModListExtension);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-22 00:26:51 +00:00
|
|
|
|
protected async Task Install(MO2Compiler compiler)
|
2019-11-02 15:38:03 +00:00
|
|
|
|
{
|
2020-03-29 03:29:27 +00:00
|
|
|
|
Utils.Log("Loading Modlist");
|
2019-11-21 15:05:10 +00:00
|
|
|
|
var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile);
|
2020-03-29 03:29:27 +00:00
|
|
|
|
Utils.Log("Constructing Installer");
|
2019-12-01 20:22:33 +00:00
|
|
|
|
var installer = new MO2Installer(
|
|
|
|
|
archive: compiler.ModListOutputFile,
|
|
|
|
|
modList: modlist,
|
|
|
|
|
outputFolder: utils.InstallFolder,
|
2020-01-07 13:50:11 +00:00
|
|
|
|
downloadFolder: utils.DownloadsFolder,
|
2020-03-26 21:15:44 +00:00
|
|
|
|
parameters: CreateDummySystemParameters());
|
2019-11-18 05:21:24 +00:00
|
|
|
|
installer.WarnOnOverwrite = false;
|
2019-11-02 15:38:03 +00:00
|
|
|
|
installer.GameFolder = utils.GameFolder;
|
2020-03-29 03:29:27 +00:00
|
|
|
|
Utils.Log("Starting Install");
|
2019-12-22 00:26:51 +00:00
|
|
|
|
await installer.Begin();
|
2019-11-02 15:38:03 +00:00
|
|
|
|
}
|
2020-03-26 21:15:44 +00:00
|
|
|
|
|
2020-03-28 18:22:53 +00:00
|
|
|
|
public static SystemParameters CreateDummySystemParameters()
|
2020-03-26 21:15:44 +00:00
|
|
|
|
{
|
|
|
|
|
return new SystemParameters
|
|
|
|
|
{
|
|
|
|
|
WindowsVersion = new Version("6.2.4.0"),
|
|
|
|
|
ScreenWidth = 1920,
|
|
|
|
|
ScreenHeight = 1080,
|
|
|
|
|
SystemMemorySize = 16 * 1024 * 1040,
|
|
|
|
|
VideoMemorySize = 4 * 1024 * 1024
|
|
|
|
|
};
|
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|