mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
96 lines
3.5 KiB
C#
96 lines
3.5 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Alphaleonis.Win32.Filesystem;
|
|||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||
|
using Wabbajack.Common;
|
|||
|
using Wabbajack.Lib;
|
|||
|
|
|||
|
namespace Wabbajack.Test
|
|||
|
{
|
|||
|
[TestClass]
|
|||
|
public class zEditIntegrationTests : ACompilerTest
|
|||
|
{
|
|||
|
[TestMethod]
|
|||
|
public void CanCreatezEditPatches()
|
|||
|
{
|
|||
|
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", 10);
|
|||
|
var srcc = utils.AddModFile(modb, @"srcd.esp", 10);
|
|||
|
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,
|
|||
|
dataFolder = Path.GetDirectoryName(srca),
|
|||
|
},
|
|||
|
new zEditIntegration.zEditMergePlugin()
|
|||
|
{
|
|||
|
filename = srcb,
|
|||
|
dataFolder = Path.GetDirectoryName(srcb),
|
|||
|
},
|
|||
|
new zEditIntegration.zEditMergePlugin()
|
|||
|
{
|
|||
|
filename = srcc,
|
|||
|
dataFolder = Path.GetDirectoryName(srcc),
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}.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"
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
var modlist = CompileAndInstall(profile);
|
|||
|
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");
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|