public static string TestMissions(object os_obj) { OS os = (OS)os_obj; string str1 = ""; string retAdditions = ""; MissionFunctions.ReportErrorInCommand += (Action <string>)(report => { // ISSUE: variable of a compiler-generated type TestSuite.\u003C\u003Ec__DisplayClass1 cDisplayClass1 = this; // ISSUE: reference to a compiler-generated field string str2 = cDisplayClass1.retAdditions + TestSuite.ActiveObjectID + " : " + report + "\r\n"; // ISSUE: reference to a compiler-generated field cDisplayClass1.retAdditions = str2; }); TestSuite.TestedMissionNames.Clear(); try { string str2 = TestSuite.TestMission("Content/Missions/BitMissionIntro.xml", (object)os); str1 += str2; string str3 = TestSuite.TestMission("Content/Missions/BitMission0.xml", (object)os); str1 += str3; string path1 = "Content/Missions/Entropy/StartingSet/"; foreach (FileSystemInfo file in new DirectoryInfo(path1).GetFiles("*.xml")) { string str4 = TestSuite.TestMission(path1 + file.Name, (object)os); str1 += str4; } string str5 = TestSuite.TestMission("Content/Missions/Entropy/ThemeHackTransitionMission.xml", (object)os); str1 += str5; string str6 = TestSuite.TestMission("Content/Missions/MainHub/Intro/Intro01.xml", (object)os); str1 += str6; string path2 = "Content/Missions/MainHub/FirstSet/"; foreach (FileSystemInfo file in new DirectoryInfo(path2).GetFiles("*.xml")) { string str4 = TestSuite.TestMission(path2 + file.Name, (object)os); str1 += str4; } string str7 = TestSuite.TestMission("Content/Missions/lelzSec/IntroTestMission.xml", (object)os); str1 += str7; string str8 = TestSuite.TestMission("Content/Missions/MainHub/BitSet/Missions/BitHubSet01.xml", (object)os); str1 += str8; string str9 = TestSuite.TestMission("Content/Missions/BitPath/BitAdv_Intro.xml", (object)os); str1 += str9; string str10 = TestSuite.TestMissionEndFucntion("Content/Missions/MainHub/FirstSet/01HubSet02.xml", "changeSong", (object)os); str1 += str10; string str11 = TestSuite.TestMissionEndFucntion("Content/Missions/MainHub/FirstSet/02HubSet05.xml", "addFlags:decypher", (object)os); str1 += str11; string str12 = TestSuite.TestMissionEndFucntion("Content/Missions/MainHub/DecypherSet/DECHeadMission02.xml", "addFlags:dechead", (object)os); str1 += str12; MissionFunctions.ReportErrorInCommand = (Action <string>)null; } finally { MissionFunctions.ReportErrorInCommand = (Action <string>)null; } return(str1 + retAdditions); }
public static string TestExtensionMissionLoading(ScreenManager screenMan, out int errorsAdded) { int num = 0; string str1 = ""; OS os = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestExtension", screenMan); string str2 = TestSuite.TestMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath, (object)os); if (!string.IsNullOrWhiteSpace(str2)) { ++num; str1 = str1 + "\n\nMISSION READ ERRORS:\n" + str2; } screenMan.RemoveScreen((GameScreen)os); ExtensionTests.CompleteExtensiontesting(); errorsAdded = num; return(str1); }
public static string TestExtensionForRuntime(ScreenManager screenMan, string path, out int errorsAdded) { int num1 = 0; string str1 = ""; OS os = (OS)null; ExtensionTests.RuntimeLoadAdditionalErrors = ""; int num2; try { os = (OS)ExtensionTests.SetupOSForTests(path, screenMan); string str2 = TestSuite.TestMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath, (object)os); if (!string.IsNullOrWhiteSpace(str2)) { ++num1; str1 = str1 + "\n\nSTART MISSION READ ERRORS:\r\n" + str2; } int errorsAdded1 = 0; string str3 = ExtensionTests.TestAllExtensionMissions(os, out errorsAdded1); str1 += str3; num1 += errorsAdded1; int errorsAdded2 = 0; string str4 = ExtensionTests.TestAllExtensionNodesRuntime(os, out errorsAdded2); str1 += str4; num2 = num1 + errorsAdded2; } catch (Exception ex) { str1 = str1 + "\nLoad Error:\n" + Utils.GenerateReportFromException(ex).Trim(); num2 = num1 + 1; } if (os != null) { screenMan.RemoveScreen((GameScreen)os); } ExtensionTests.CompleteExtensiontesting(); if (!string.IsNullOrWhiteSpace(ExtensionTests.RuntimeLoadAdditionalErrors)) { ++num2; str1 = str1 + "\r\n" + ExtensionTests.RuntimeLoadAdditionalErrors; } errorsAdded = num2; return(str1); }
public static string TestExtensionMission(object mission, string filepath, object os) { string str1 = ""; ActiveMission activeMission = (ActiveMission)mission; string str2 = File.ReadAllText(filepath); string str3 = str1 + ExtensionTests.TestTagisClosed("missionEnd", str2) + ExtensionTests.TestTagisClosed("missionStart", str2) + ExtensionTests.TestTagisClosed("nextMission", str2) + ExtensionTests.TestTagisClosed("goals", str2) + ExtensionTests.TestTagisClosed("email", str2) + ExtensionTests.TestTagisClosed("sender", str2) + ExtensionTests.TestTagisClosed("subject", str2) + ExtensionTests.TestTagisClosed("body", str2) + ExtensionTests.TestTagisClosed("attachments", str2); if (!str2.Contains("</attachments>")) { str3 = str3 + "File does not contain attachments tag at the end of the email! It needs to be there!" + "\r\n"; } int count = Regex.Matches(str2, "<goal ").Count; if (activeMission.goals.Count != count && activeMission.goals.Count < count) { string str4 = str3 + "File defines some goals that are not being correctly parsed in! (" + (object)activeMission.goals.Count + " loaded vs " + (object)count + " in file)" + "\r\nCheck your syntax and tags! Valid Goals:\r\n"; for (int index = 0; index < activeMission.goals.Count; ++index) { str4 = str4 + "\r\n" + activeMission.goals[index].ToString().Replace("Hacknet.Mission.", ""); } str3 = str4 + "\r\n"; } if (string.IsNullOrWhiteSpace(activeMission.startFunctionName) && str2.Contains("<missionStart")) { str3 = str3 + "File contains missionStart, but it's not being correctly parsed in. It might be out of order in the file." + "\r\n"; } if (activeMission.startFunctionName != null) { try { if (!activeMission.startFunctionName.Contains("addRank")) { MissionFunctions.runCommand(activeMission.startFunctionValue, activeMission.startFunctionName); } } catch (Exception ex) { str3 = str3 + "Error running start function " + activeMission.startFunctionName + "\r\n" + Utils.GenerateReportFromException(ex); } } if (string.IsNullOrWhiteSpace(activeMission.endFunctionName) && str2.Contains("<missionEnd")) { str3 = str3 + "File contains missionEnd, but it's not being correctly parsed in. It might be out of order in the file." + "\r\n"; } if (activeMission.endFunctionName != null) { try { if (!activeMission.endFunctionName.Contains("addRank")) { MissionFunctions.runCommand(activeMission.endFunctionValue, activeMission.endFunctionName); } } catch (Exception ex) { str3 = str3 + "Error running end function " + activeMission.endFunctionName + "\r\n" + Utils.GenerateReportFromException(ex); } } string str5 = TestSuite.TestMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath, os); if (!string.IsNullOrWhiteSpace(str5)) { str3 += str5; } if (str3.Length > 1) { return("Mission Errors for " + filepath.Replace("\\", "/") + ":\r\n" + str3); } return(""); }
public static string TestMission(string missionName, object os_obj) { string str1 = ""; OS os = (OS)os_obj; if (TestSuite.TestedMissionNames.Contains(missionName)) { return(str1); } try { if (!File.Exists(missionName)) { str1 = str1 + "Invalid Mission Path! : " + missionName + "\r\n"; } ActiveMission activeMission = (ActiveMission)ComputerLoader.readMission(missionName); TestSuite.ActiveObjectID = missionName; string str2 = ""; for (int index = 0; index < activeMission.goals.Count; ++index) { string str3 = activeMission.goals[index].TestCompletable(); if (str3 != null && str3.Length > 0) { str2 = str2 + missionName + " Goal[" + (object)index + "] " + activeMission.goals[index].ToString() + " :: " + str3 + "\r\n"; } } try { if (!string.IsNullOrWhiteSpace(activeMission.startFunctionName)) { if (!Utils.CheckStringIsRenderable(activeMission.startFunctionName)) { str1 = str1 + "Mission " + missionName + " has unrenderable start function " + Utils.CleanStringToRenderable(activeMission.startFunctionName); } MissionFunctions.runCommand(activeMission.startFunctionValue, activeMission.startFunctionName); } if (!string.IsNullOrWhiteSpace(activeMission.endFunctionName)) { if (!Utils.CheckStringIsRenderable(activeMission.endFunctionName)) { str1 = str1 + "Mission " + missionName + " has unrenderable end function " + Utils.CleanStringToRenderable(activeMission.endFunctionName); } MissionFunctions.runCommand(activeMission.endFunctionValue, activeMission.endFunctionName); } string str3 = Directory.GetCurrentDirectory() + "/"; string fileLoadPrefix = Utils.GetFileLoadPrefix(); if (fileLoadPrefix == "Content/") { fileLoadPrefix += "Missions/"; } else if (!fileLoadPrefix.StartsWith("Extensions")) { str3 = ""; } string path = str3 + LocalizedFileLoader.GetLocalizedFilepath(fileLoadPrefix + activeMission.nextMission); if (!(activeMission.nextMission == "NONE") && !File.Exists(path)) { str1 = str1 + "\r\nNextMission Tag for mission \"" + missionName + "\" has nonexistent next mission path: " + activeMission.nextMission + "\r\n"; } } catch (Exception ex) { str1 = str1 + "Error running start or end mission function of mission: " + missionName + "\r\nStart Func: " + activeMission.startFunctionName + "\r\nEnd Func: " + activeMission.endFunctionName; str1 = str1 + "\r\n" + Utils.GenerateReportFromException(ex) + "\r\n"; } if (str2.Length > 0) { str1 = str1 + str2 + "--------------\r\n"; } TestSuite.TestedMissionNames.Add(missionName); string str4 = "Content/Missions/"; if (Settings.IsInExtensionMode) { str4 = ExtensionLoader.ActiveExtensionInfo.FolderPath + "/"; } List <ActiveMission> activeMissionList = new List <ActiveMission>(); for (int index = 0; index < os.branchMissions.Count; ++index) { activeMissionList.Add(os.branchMissions[index]); } if (activeMission.nextMission != null && activeMission.nextMission.ToLower() != "none") { str1 += TestSuite.TestMission(str4 + activeMission.nextMission, (object)os); } for (int index = 0; index < activeMissionList.Count; ++index) { string localizedFilepath = LocalizedFileLoader.GetLocalizedFilepath(activeMissionList[index].reloadGoalsSourceFile); if (!TestSuite.TestedMissionNames.Contains(localizedFilepath)) { Console.WriteLine("testing Branch Mission " + localizedFilepath); str1 += TestSuite.TestMission(localizedFilepath, (object)os); } } } catch (Exception ex) { str1 = str1 + "Error Loading " + missionName + "\r\n" + ex.ToString(); } return(str1); }