wabbajack/Wabbajack.Test/TasksTests.cs

50 lines
1.9 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
using Wabbajack.Common;
using Wabbajack.Lib.Tasks;
using Xunit;
2020-05-04 12:11:53 +00:00
using Xunit.Abstractions;
namespace Wabbajack.Test
{
2020-05-04 12:11:53 +00:00
public class TasksTests : ACompilerTest
{
[Fact]
public async Task CanRemapGameFolder()
{
await using var tempFolder = await TempFolder.Create();
2020-05-04 12:11:53 +00:00
var gameff = tempFolder.Dir.Combine(Consts.GameFolderFilesDir);
gameff.CreateDirectory();
2020-05-04 12:11:53 +00:00
await gameff.Combine("some_file.txt").WriteAllTextAsync("some_file");
await gameff.Combine("steam_api64.dll").WriteAllTextAsync("steam_api");
var meta = Game.SkyrimSpecialEdition.MetaData();
await tempFolder.Dir.Combine(Consts.ModOrganizer2Ini)
.WriteAllLinesAsync(
"[General]",
$"gameName={meta.MO2Name}",
$"gamePath={meta.GameLocation()}",
$"pathDouble={meta.GameLocation().ToString().Replace(@"\", @"\\")}",
$"pathForward={meta.GameLocation().ToString().Replace(@"\", @"/")}");
2020-05-04 12:11:53 +00:00
Assert.True(await MigrateGameFolder.Execute(tempFolder.Dir));
2020-05-04 12:11:53 +00:00
Assert.Equal("some_file", await gameff.Combine("some_file.txt").ReadAllTextAsync());
Assert.Equal("steam_api", await gameff.Combine("steam_api64.dll").ReadAllTextAsync());
Assert.Equal(Hash.FromBase64("k5EWx/9Woqg="), await gameff.Combine(@"Data\Skyrim - Interface.bsa").FileHashAsync());
var ini = tempFolder.Dir.Combine(Consts.ModOrganizer2Ini).LoadIniFile();
Assert.Equal(gameff, (AbsolutePath)(string)ini.General.gamePath);
Assert.Equal(gameff, (AbsolutePath)(string)ini.General.pathDouble);
Assert.Equal(gameff, (AbsolutePath)(string)ini.General.pathForward);
}
2020-05-04 12:11:53 +00:00
public TasksTests(ITestOutputHelper helper) : base(helper)
{
}
}
}