2019-09-24 04:20:24 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-11-02 21:08:37 +00:00
|
|
|
|
using System.IO;
|
2019-09-26 23:08:10 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime;
|
2019-09-24 04:20:24 +00:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
|
|
|
|
|
using VFS;
|
|
|
|
|
using Wabbajack.Common;
|
2019-10-16 03:10:34 +00:00
|
|
|
|
using Wabbajack.Lib;
|
2019-11-02 21:08:37 +00:00
|
|
|
|
using File = Alphaleonis.Win32.Filesystem.File;
|
|
|
|
|
using Path = Alphaleonis.Win32.Filesystem.Path;
|
2019-09-24 04:20:24 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Test
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
2019-10-31 02:24:42 +00:00
|
|
|
|
public class SanityTests : ACompilerTest
|
2019-09-24 04:20:24 +00:00
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void TestDirectMatch()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var profile = utils.AddProfile();
|
|
|
|
|
var mod = utils.AddMod();
|
|
|
|
|
var test_pex = utils.AddModFile(mod, @"Data\scripts\test.pex", 10);
|
2019-09-26 22:32:15 +00:00
|
|
|
|
|
2019-09-24 04:20:24 +00:00
|
|
|
|
utils.Configure();
|
|
|
|
|
|
|
|
|
|
utils.AddManualDownload(
|
2019-09-26 22:32:15 +00:00
|
|
|
|
new Dictionary<string, byte[]> {{"/baz/biz.pex", File.ReadAllBytes(test_pex)}});
|
2019-09-24 04:20:24 +00:00
|
|
|
|
|
2019-09-26 23:08:10 +00:00
|
|
|
|
CompileAndInstall(profile);
|
2019-09-24 04:20:24 +00:00
|
|
|
|
|
2019-09-26 22:32:15 +00:00
|
|
|
|
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex");
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-02 21:08:37 +00:00
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CleanedESMTest()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var profile = utils.AddProfile();
|
|
|
|
|
var mod = utils.AddMod("Cleaned ESMs");
|
|
|
|
|
var update_esm = utils.AddModFile(mod, @"Update.esm", 10);
|
|
|
|
|
|
|
|
|
|
utils.Configure();
|
|
|
|
|
|
|
|
|
|
var game_file = Path.Combine(utils.GameFolder, "Data", "Update.esm");
|
|
|
|
|
utils.GenerateRandomFileData(game_file, 20);
|
|
|
|
|
|
|
|
|
|
var modlist = CompileAndInstall(profile);
|
|
|
|
|
|
|
|
|
|
utils.VerifyInstalledFile(mod, @"Update.esm");
|
|
|
|
|
|
|
|
|
|
var compiler = ConfigureAndRunCompiler(profile);
|
|
|
|
|
|
|
|
|
|
// Update the file and verify that it throws an error.
|
|
|
|
|
utils.GenerateRandomFileData(game_file, 20);
|
|
|
|
|
var exception = Assert.ThrowsException<Exception>(() => Install(compiler));
|
|
|
|
|
Assert.AreEqual(exception.Message, "Game ESM hash doesn't match, is the ESM already cleaned? Please verify your local game files.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 23:08:10 +00:00
|
|
|
|
[TestMethod]
|
|
|
|
|
public void UnmodifiedInlinedFilesArePulledFromArchives()
|
|
|
|
|
{
|
|
|
|
|
var profile = utils.AddProfile();
|
|
|
|
|
var mod = utils.AddMod();
|
|
|
|
|
var ini = utils.AddModFile(mod, @"foo.ini", 10);
|
|
|
|
|
utils.Configure();
|
|
|
|
|
|
|
|
|
|
utils.AddManualDownload(
|
|
|
|
|
new Dictionary<string, byte[]> { { "/baz/biz.pex", File.ReadAllBytes(ini) } });
|
|
|
|
|
|
|
|
|
|
var modlist = CompileAndInstall(profile);
|
|
|
|
|
var directive = modlist.Directives.Where(m => m.To == $"mods\\{mod}\\foo.ini").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(directive);
|
|
|
|
|
Assert.IsInstanceOfType(directive, typeof(FromArchive));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void ModifiedIniFilesArePatchedAgainstFileWithSameName()
|
|
|
|
|
{
|
|
|
|
|
var profile = utils.AddProfile();
|
|
|
|
|
var mod = utils.AddMod();
|
|
|
|
|
var ini = utils.AddModFile(mod, @"foo.ini", 10);
|
|
|
|
|
utils.Configure();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.AddManualDownload(
|
|
|
|
|
new Dictionary<string, byte[]> { { "/baz/foo.ini", File.ReadAllBytes(ini) } });
|
|
|
|
|
|
|
|
|
|
// Modify after creating mod archive in the downloads folder
|
|
|
|
|
File.WriteAllText(ini, "Wabbajack, Wabbajack, Wabbajack!");
|
|
|
|
|
|
|
|
|
|
var modlist = CompileAndInstall(profile);
|
|
|
|
|
var directive = modlist.Directives.Where(m => m.To == $"mods\\{mod}\\foo.ini").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(directive);
|
|
|
|
|
Assert.IsInstanceOfType(directive, typeof(PatchedFromArchive));
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-24 04:20:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|