wabbajack/Wabbajack.Test/ZEditIntegrationTests.cs

108 lines
4.1 KiB
C#
Raw Normal View History

2019-11-21 14:27:35 +00:00
using System.Collections.Generic;
2019-11-02 15:38:03 +00:00
using System.Linq;
2019-12-07 02:54:27 +00:00
using System.Threading.Tasks;
2019-11-02 15:38:03 +00:00
using Alphaleonis.Win32.Filesystem;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack.Test
{
[TestClass]
public class zEditIntegrationTests : ACompilerTest
{
[TestMethod]
2019-12-07 02:54:27 +00:00
public async Task CanCreatezEditPatches()
2019-11-02 15:38:03 +00:00
{
var profile = utils.AddProfile();
var moda = await utils.AddMod();
var modb = await utils.AddMod();
var moddest = await utils.AddMod();
var srca = await utils.AddModFile(moda, @"srca.esp", 10);
var srcb = await utils.AddModFile(moda, @"srcb.esp.mohidden", 10);
var srcc = await utils.AddModFile(modb, @"optional\srcc.esp", 10);
var dest = await utils.AddModFile(moddest, @"merged.esp", 20);
2019-11-02 15:38:03 +00:00
var srcs = new List<string> {srca, srcb, srcc};
Directory.CreateDirectory(Path.Combine(utils.MO2Folder, "tools", "mator", "bleh", "profiles", "myprofile"));
2020-04-04 17:10:13 +00:00
var settings = new zEditIntegration.zEditSettings()
{
modManager = "Mod Organizer 2",
managerPath = utils.MO2Folder,
modsPath = Path.Combine(utils.MO2Folder, Consts.MO2ModFolderName),
mergePath = Path.Combine(utils.MO2Folder, Consts.MO2ModFolderName)
};
settings.ToJson(Path.Combine(utils.MO2Folder, "tools", "mator", "bleh", "profiles", "myprofile",
2020-04-04 17:10:13 +00:00
"settings.json"));
2019-11-02 15:38:03 +00:00
new List<zEditIntegration.zEditMerge>()
{
new zEditIntegration.zEditMerge()
{
name = moddest,
filename = "merged.esp",
plugins = new List<zEditIntegration.zEditMergePlugin>()
{
new zEditIntegration.zEditMergePlugin()
{
filename = "srca.esp",
2020-02-05 05:17:12 +00:00
dataFolder = Path.Combine(utils.MO2Folder, Consts.MO2ModFolderName, moda)
2019-11-02 15:38:03 +00:00
},
new zEditIntegration.zEditMergePlugin()
{
filename = "srcb.esp",
2020-02-05 05:17:12 +00:00
dataFolder = Path.Combine(utils.MO2Folder, Consts.MO2ModFolderName, moda),
2019-11-02 15:38:03 +00:00
},
new zEditIntegration.zEditMergePlugin()
{
filename = "srcc.esp",
2020-02-05 05:17:12 +00:00
dataFolder = Path.Combine(utils.MO2Folder, Consts.MO2ModFolderName, modb),
2019-11-02 15:38:03 +00:00
}
}
}
}.ToJson(Path.Combine(utils.MO2Folder, "tools", "mator", "bleh", "profiles", "myprofile", "merges.json"));
2019-11-02 15:38:03 +00:00
utils.Configure();
utils.AddManualDownload(
new Dictionary<string, byte[]> { { "srca.esp", File.ReadAllBytes(srca) } });
utils.AddManualDownload(
new Dictionary<string, byte[]> { { "srcb.esp", File.ReadAllBytes(srcb) } });
utils.AddManualDownload(
new Dictionary<string, byte[]> { { "srcc.esp", File.ReadAllBytes(srcc) } });
File.AppendAllLines(Path.Combine(utils.MO2Folder, "ModOrganizer.ini"),
new List<string>
{
"[customExecutables]",
"size=1",
$@"1\binary={utils.MO2Folder.Replace('\\','/')}/tools/mator/bleh/zEdit.exe"
});
2020-01-06 23:08:19 +00:00
2019-12-07 02:54:27 +00:00
var modlist = await CompileAndInstall(profile);
2019-11-02 15:38:03 +00:00
var directive = modlist.Directives.Where(m => m.To == $"mods\\{moddest}\\merged.esp").FirstOrDefault();
Assert.IsNotNull(directive);
Assert.IsInstanceOfType(directive, typeof(MergedPatch));
var merged = directive as MergedPatch;
foreach (var (source, path) in merged.Sources.Zip(srcs, (a, b) => (a, b)))
{
Assert.AreEqual(source.Hash, Utils.FileHash(path));
}
utils.VerifyInstalledFile(moddest, "merged.esp");
}
}
}