public Test TestImport() { return(TestBattery.RunTest("Test Import", GameRelease, Target, async(output) => { await ImportBinary(this.FilePath.Path); })); }
public Test TestPex() { return(TestBattery.RunTest("Pex", GameRelease, Target, async(output) => { IEnumerable <FileName> bsas; if (Implicits.Get(GameRelease).BaseMasters.Contains(FilePath.ModKey)) { bsas = Archive.GetIniListings(GameRelease).ToList(); } else { bsas = new FileName($"{FilePath.ModKey.Name}.{Archive.GetExtension(GameRelease)}").AsEnumerable(); } foreach (var bsa in bsas) { var archive = Archive.CreateReader(GameRelease, Path.Combine(Path.GetDirectoryName(FilePath) !, bsa.String)); foreach (var file in archive.Files) { if (!Path.GetExtension(file.Path).Equals(".pex", StringComparison.OrdinalIgnoreCase)) { continue; } TestPex(GameRelease, file.GetMemorySlice()); } } })); }
public Test TestEquality() { return(TestBattery.RunTest("Equals", GameRelease, Target, async(output) => { var mod = await ImportBinaryOverlay(this.FilePath.Path); var eqMask = mod.GetEqualsMask(mod); if (!eqMask.All(b => b)) { throw new Exception("Mod mask did not equal itself"); } System.Console.WriteLine("Equals mask clean."); if (!mod.Equals(mod)) { throw new Exception("Mod did not equal itself"); } System.Console.WriteLine("Direct equals matched."); })); }
public Test BinaryPassthroughTest() { (TempFolder tmp, Test processedTest) = SetupProcessedFiles(); var outputPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_NormalExport"); var processedPath = ProcessedPath(tmp); var orderedPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_Ordered"); var binaryOverlayPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_BinaryOverlay"); var copyInPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_CopyIn"); var strsProcessedPath = Path.Combine(tmp.Dir.Path, "Strings/Processed"); var masterRefs = MasterReferenceReader.FromPath(new ModPath(ModKey, this.FilePath.Path), GameRelease); // Do normal if (Settings.TestNormal) { var strsWriteDir = Path.Combine(tmp.Dir.Path, "Strings", $"{this.Nickname}_Normal"); bool doStrings = false; var passthrough = TestBattery.RunTest( "Binary Normal Passthrough", this.GameRelease, this.Target, parallel: Settings.Parallel, toDo: async(o) => { o.OnNext(FilePath.ToString()); var mod = await ImportBinary(this.FilePath.Path); doStrings = mod.UsingLocalization; foreach (var record in mod.EnumerateMajorRecords()) { record.IsCompressed = false; } var writeParam = GetWriteParam(masterRefs, doStrings ? new StringsWriter(mod.ModKey, strsWriteDir) : null); mod.WriteToBinary(outputPath, writeParam); GC.Collect(); using var stream = new MutagenBinaryReadStream(processedPath, this.GameRelease); writeParam.StringsWriter?.Dispose(); AssertFilesEqual( stream, outputPath, amountToReport: 15); }); processedTest.AddAsChild(passthrough); if (doStrings) { foreach (var item in AssertStringsEqual( "Binary Normal", strsProcessedPath, strsWriteDir)) { passthrough.AddAsChild(item); } } } if (Settings.TestBinaryOverlay) { var strsWriteDir = Path.Combine(tmp.Dir.Path, "Strings", $"{this.Nickname}_Overlay"); bool doStrings = false; var passthrough = TestBattery.RunTest( "Binary Overlay Passthrough", this.GameRelease, this.Target, parallel: Settings.Parallel, toDo: async(o) => { o.OnNext(FilePath.ToString()); using (var wrapper = await ImportBinaryOverlay(this.FilePath.Path)) { doStrings = wrapper.UsingLocalization; var writeParam = GetWriteParam(masterRefs, doStrings ? new StringsWriter(wrapper.ModKey, strsWriteDir) : null); wrapper.WriteToBinary(binaryOverlayPath, writeParam); writeParam.StringsWriter?.Dispose(); } using var stream = new MutagenBinaryReadStream(processedPath, this.GameRelease); PassthroughTest.AssertFilesEqual( stream, binaryOverlayPath, amountToReport: 15); }); processedTest.AddAsChild(passthrough); if (doStrings) { foreach (var item in AssertStringsEqual( "Binary Overlay", strsProcessedPath, strsWriteDir)) { passthrough.AddAsChild(item); } } } if (Settings.TestCopyIn) { var strsWriteDir = Path.Combine(tmp.Dir.Path, "Strings", $"{this.Nickname}_CopyIn"); bool doStrings = false; var passthrough = TestBattery.RunTest( "Copy In Passthrough", this.GameRelease, this.Target, parallel: Settings.Parallel, toDo: async(o) => { o.OnNext(FilePath.ToString()); var copyIn = await ImportCopyIn(this.FilePath.Path); doStrings = copyIn.UsingLocalization; var writeParam = GetWriteParam(masterRefs, doStrings ? new StringsWriter(copyIn.ModKey, strsWriteDir) : null); copyIn.WriteToBinary(copyInPath, writeParam); writeParam.StringsWriter?.Dispose(); using var stream = new MutagenBinaryReadStream(processedPath, this.GameRelease); PassthroughTest.AssertFilesEqual( stream, copyInPath, amountToReport: 15); }); processedTest.AddAsChild(passthrough); if (doStrings) { foreach (var item in AssertStringsEqual( "Copy In", strsProcessedPath, strsWriteDir)) { passthrough.AddAsChild(item); } } } return(processedTest); }