[TestCase("206102", GameVersion.RS2012)] // free ODLC Holiday Song Pack - no messagebox public void TestRepackAppId(string appId, GameVersion gameVersion) { // start fresh TestSettings.Instance.CopyResources(); if (!TestSettings.Instance.ArchivePaths.Any()) { Assert.Fail("TestSettings CopyResources Failed ..."); } packerUnpacker.Version = gameVersion; packerUnpacker.AppId = appId; foreach (var archivePath in TestSettings.Instance.ArchivePaths) { var platform = archivePath.GetPlatform(); if (gameVersion != platform.version) { continue; } // console package does not have an AppId if (platform.IsConsole) { // NOTE: when unit test is finished, double click the test result to see this message Debug.WriteLine("---------------------------------"); Debug.WriteLine("TestRepackAppId skipped console files: " + Path.GetFileName(archivePath)); Debug.WriteLine("---------------------------------"); continue; } // test AppId validation method packerUnpacker.SelectComboAppId(packerUnpacker.AppId); // call background worker method from unit test to avoid threading issues packerUnpacker.UpdateAppId(null, new DoWorkEventArgs(new string[] { archivePath })); if (!File.Exists(archivePath)) { Assert.Fail("RepackAppId Method Failed: " + Path.GetFileName(archivePath)); } if (gameVersion == GameVersion.RS2012) { continue; } // check if RepackAppId wrote the new AppId (RS2014 ONLY) using (var psarcLoader = new PsarcLoader(archivePath, true)) { var entryAppId = psarcLoader.ExtractAppId(); Assert.AreEqual(packerUnpacker.AppId, entryAppId); } } }
public void TestPackageGenerate() { var archivePaths = new List <string>(); foreach (var srcPath in TestSettings.Instance.ResourcePaths) { Debug.WriteLine("Processing: " + srcPath); // load info from srcPath DLCPackageData info = new DLCPackageData(); var platform = srcPath.GetPlatform(); if (platform.version == GameVersion.RS2012) { packageCreator.CurrentGameVersion = GameVersion.RS2012; } else { packageCreator.CurrentGameVersion = GameVersion.RS2014; } info = packageCreator.PackageImport(srcPath, TestSettings.Instance.TmpDestDir); // set package version, old srcPackage may not have it packageCreator.PackageVersion = "8"; // make easy to identify packageCreator.AppId = "492988"; // free Bob Marley - Three Little Birds // stress test package generation for all platforms packageCreator.PlatformPC = true; packageCreator.PlatformXBox360 = true; packageCreator.PlatformPS3 = true; packageCreator.PlatformMAC = true; // skip testing ddc generation // ConfigRepository.Instance()["ddc_autogen"] = "false"; if (packageCreator.CurrentGameVersion == GameVersion.RS2012) { packageCreator.AppId = "206102"; // free Holiday Song Pack packageCreator.PlatformPS3 = false; packageCreator.PlatformMAC = false; } // set destPath and test getting the package data var archivePath = Path.Combine(TestSettings.Instance.TmpDestDir, Path.GetFileName(srcPath)); packageCreator.DestPath = archivePath; var packageData = packageCreator.PackageGenerate(); Assert.NotNull(packageData); // call background worker method from unit test to avoid threading issues packageCreator.GeneratePackage(null, new DoWorkEventArgs(packageData)); var shortPath = archivePath.Replace("_p.psarc", "").Replace("_m.psarc", "").Replace("_ps3.psarc.edat", "").Replace("_xbox", "").Replace(".dat", ""); if (packageCreator.CurrentGameVersion == GameVersion.RS2012) { if (!File.Exists(shortPath + ".dat")) { Assert.Fail("RS1 PC Package Generation Failed ..."); } if (!File.Exists(shortPath + "_xbox")) { Assert.Fail("RS1 Xbox Package Generation Failed ..."); } } else { if (!File.Exists(shortPath + "_p.psarc")) { Assert.Fail("PC Package Generation Failed ..."); } if (!File.Exists(shortPath + "_m.psarc")) { Assert.Fail("Mac Package Generation Failed ..."); } if (!File.Exists(shortPath + "_xbox")) { Assert.Fail("Xbox Package Generation Failed ..."); } if (!File.Exists(shortPath + "_ps3.psarc.edat")) { Assert.Fail("PS3 Package Generation Failed ..."); } // console files do not contain an AppId if (!info.PS3 && !info.XBox360) { // check if GeneratePackage wrote the new AppId using (var psarcLoader = new PsarcLoader(archivePath, true)) { var entryAppId = psarcLoader.ExtractAppId(); Assert.AreEqual(packageCreator.AppId, entryAppId); } } } archivePaths.Add(archivePath); } Assert.AreEqual(TestSettings.Instance.ResourcePaths.Count, archivePaths.Count); }