2021-09-27 12:42:46 +00:00
|
|
|
using System;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Wabbajack.DTOs.JsonConverters;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
using Wabbajack.Paths.IO;
|
|
|
|
using Xunit;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.Installer.Test;
|
|
|
|
|
|
|
|
public class StandardInstallerTest
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
private readonly StandardInstaller _installer;
|
|
|
|
private readonly TemporaryFileManager _manager;
|
|
|
|
private readonly AbsolutePath _modList;
|
|
|
|
private readonly IServiceProvider _provider;
|
|
|
|
private readonly DTOSerializer _serializer;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public StandardInstallerTest(IServiceProvider provider, DTOSerializer serializer, TemporaryFileManager manager)
|
|
|
|
{
|
|
|
|
_provider = provider;
|
|
|
|
_serializer = serializer;
|
|
|
|
_modList = "TestData/MO2AndSKSETest.wabbajack".ToRelativePath().RelativeTo(KnownFolders.EntryPoint);
|
|
|
|
_manager = manager;
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
[Fact]
|
|
|
|
public async Task CanLoadModlistDefinition()
|
|
|
|
{
|
|
|
|
var modlist = await StandardInstaller.LoadFromFile(_serializer, _modList);
|
|
|
|
Assert.Equal("MO2AndSKSETest", modlist.Name);
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
[Fact]
|
|
|
|
public async Task CanInstallAList()
|
|
|
|
{
|
|
|
|
var modlist = await StandardInstaller.LoadFromFile(_serializer, _modList);
|
|
|
|
using var scope = _provider.CreateScope();
|
|
|
|
var config = _provider.GetService<InstallerConfiguration>()!;
|
|
|
|
await using var installFolder = _manager.CreateFolder();
|
|
|
|
config.Install = installFolder;
|
|
|
|
config.Downloads = config.Install.Combine("downloads");
|
|
|
|
config.ModlistArchive = _modList;
|
|
|
|
config.ModList = modlist;
|
|
|
|
config.Game = modlist.GameType;
|
|
|
|
config.SystemParameters = new SystemParameters
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
ScreenWidth = 1920,
|
|
|
|
ScreenHeight = 1080,
|
|
|
|
SystemMemorySize = 8L * 1024 * 1024 * 1024,
|
|
|
|
SystemPageSize = 8L * 1024 * 1024 * 1024,
|
|
|
|
VideoMemorySize = 8L * 1024 * 1024 * 1024
|
|
|
|
};
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
var installer = _provider.GetService<StandardInstaller>();
|
|
|
|
Assert.True(await installer.Begin(CancellationToken.None));
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
Assert.True("ModOrganizer.exe".ToRelativePath().RelativeTo(installFolder).FileExists());
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
|
|
|
}
|