wabbajack/Wabbajack.Test/ZEditIntegrationTests.cs

96 lines
3.6 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 = utils.AddMod();
var modb = utils.AddMod();
var moddest = utils.AddMod();
var srca = utils.AddModFile(moda, @"srca.esp", 10);
var srcb = utils.AddModFile(moda, @"srcb.esp.mohidden", 10);
var srcc = utils.AddModFile(modb, @"optional\srcc.esp", 10);
2019-11-02 15:38:03 +00:00
var dest = utils.AddModFile(moddest, @"merged.esp", 20);
var srcs = new List<string> {srca, srcb, srcc};
Directory.CreateDirectory(Path.Combine(utils.MO2Folder, "tools", "mator", "bleh", "profiles", "myprofile"));
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"));
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");
}
}
}