Exemple #1
0
        public static string TestExtensionCustomThemeFile(ScreenManager screenMan, out int errorsAdded)
        {
            int    num = 0;
            string str = "";
            OS     os1 = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestExtension", screenMan);

            if (ThemeManager.getThemeForDataString(Programs.getComputer(os1, "advExamplePC").files.root.searchForFolder("sys").searchForFile("Custom_x-server.sys").data) != OSTheme.Custom || ThemeManager.LastLoadedCustomTheme == null)
            {
                ++num;
                str += "Custom theme did not read in from file correctly!";
            }
            os1.threadedSaveExecute(false);
            screenMan.RemoveScreen((GameScreen)os1);
            OS.WillLoadSave = true;
            OS os2 = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestExtension", screenMan);

            if (ThemeManager.getThemeForDataString(Programs.getComputer(os2, "advExamplePC").files.root.searchForFolder("sys").searchForFile("Custom_x-server.sys").data) != OSTheme.Custom || ThemeManager.LastLoadedCustomTheme == null)
            {
                ++num;
                str += "Custom theme did not read in from file correctly after save/load!";
            }
            screenMan.RemoveScreen((GameScreen)os2);
            ExtensionTests.CompleteExtensiontesting();
            errorsAdded = num;
            return(str);
        }
Exemple #2
0
        public static string TestExtensionStartNodeVisibility(ScreenManager screenMan, out int errorsAdded)
        {
            int    num = 0;
            string str = "";
            OS     os  = (OS)ExtensionTests.SetupOSForTests("Content/Tests/IntroExtension", screenMan);

            for (int index = 0; index < os.netMap.nodes.Count; ++index)
            {
                string idName = os.netMap.nodes[index].idName;
                if (os.netMap.visibleNodes.Contains(index) && (!(idName == "playerComp") && !((IEnumerable <string>)ExtensionLoader.ActiveExtensionInfo.StartingVisibleNodes).Contains <string>(idName) && !((IEnumerable <string>)ExtensionLoader.ActiveExtensionInfo.StartingVisibleNodes).Contains <string>(os.netMap.nodes[index].ip)))
                {
                    ++num;
                    str = str + "\nNode is discovered but it should not be! Node: " + idName;
                }
            }
            for (int index = 0; index < ExtensionLoader.ActiveExtensionInfo.StartingVisibleNodes.Length; ++index)
            {
                string   startingVisibleNode = ExtensionLoader.ActiveExtensionInfo.StartingVisibleNodes[index];
                Computer computer            = Programs.getComputer(os, startingVisibleNode);
                if (computer != null && !os.netMap.visibleNodes.Contains(os.netMap.nodes.IndexOf(computer)))
                {
                    ++num;
                    str = str + "\nNode " + startingVisibleNode + " should be discovered, but it is not! It's on the starting visible list";
                }
            }
            screenMan.RemoveScreen((GameScreen)os);
            ExtensionTests.CompleteExtensiontesting();
            errorsAdded = num;
            return(str);
        }
Exemple #3
0
        public static string TestExtensions(ScreenManager screenMan, out int errorsAdded)
        {
            string str1         = "";
            int    errorsAdded1 = 0;
            string str2         = str1 + ExtensionTests.TestBlankExtension(screenMan, out errorsAdded1) + "\r\nComplete - " + (object)errorsAdded1 + " errors found";

            errorsAdded = errorsAdded1;
            return(str2);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        public static string TestExtensionCustomFactions(ScreenManager screenMan, out int errorsAdded)
        {
            int    errorsAdded1 = 0;
            string str1         = "";
            OS     os1          = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestExtension", screenMan);
            string str2         = str1 + ExtensionTests.TestExtensionsFactions(os1.allFactions, out errorsAdded1);

            os1.threadedSaveExecute(false);
            screenMan.RemoveScreen((GameScreen)os1);
            OS.WillLoadSave = true;
            OS     os2  = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestExtension", screenMan);
            string str3 = str2 + ExtensionTests.TestExtensionsFactions(os2.allFactions, out errorsAdded1);

            screenMan.RemoveScreen((GameScreen)os2);
            ExtensionTests.CompleteExtensiontesting();
            errorsAdded = errorsAdded1;
            return(str3);
        }
Exemple #7
0
        public static string TestPopulatedExtension(ScreenManager screenMan, out int errorsAdded)
        {
            int             currentErrorCount = 0;
            string          str1  = "";
            OS              os1   = (OS)ExtensionTests.SetupOSForTests("Content/Tests/IntroExtension", screenMan);
            List <Computer> nodes = os1.netMap.nodes;
            string          str2  = str1 + ExtensionTests.TestPopulatedExtensionRead((object)os1, out currentErrorCount);

            os1.threadedSaveExecute(false);
            screenMan.RemoveScreen((GameScreen)os1);
            OS.WillLoadSave = true;
            OS     os2  = (OS)ExtensionTests.SetupOSForTests("Content/Tests/IntroExtension", screenMan);
            string str3 = str2 + ExtensionTests.TestPopulatedExtensionRead((object)os2, out currentErrorCount) + TestSuite.getTestingReportForLoadComparison((object)os2, nodes, currentErrorCount, out currentErrorCount);

            screenMan.RemoveScreen((GameScreen)os2);
            ExtensionTests.CompleteExtensiontesting();
            errorsAdded = currentErrorCount;
            return(str3);
        }
Exemple #8
0
        private static string TestAllExtensionMissions(OS os, out int errorsAdded)
        {
            int    errors = 0;
            string ret    = "";

            Utils.ActOnAllFilesRevursivley(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/Missions", (Action <string>)(filename =>
            {
                if (!filename.EndsWith(".xml"))
                {
                    return;
                }
                if (OS.TestingPassOnly)
                {
                    try
                    {
                        ActiveMission activeMission = (ActiveMission)ComputerLoader.readMission(filename);
                        if (activeMission != null)
                        {
                            ExtensionTests.RuntimeLoadAdditionalErrors += ExtensionTests.TestExtensionMission((object)activeMission, filename, (object)os);
                        }
                    }
                    catch (Exception ex)
                    {
                        ++errors;
                        // ISSUE: variable of a compiler-generated type
                        ExtensionTests.\u003C\u003Ec__DisplayClass1 cDisplayClass1_1 = this;
                        // ISSUE: reference to a compiler-generated field
                        string str1 = cDisplayClass1_1.ret + "Error Loading Mission: " + filename;
                        // ISSUE: reference to a compiler-generated field
                        cDisplayClass1_1.ret = str1;
                        // ISSUE: variable of a compiler-generated type
                        ExtensionTests.\u003C\u003Ec__DisplayClass1 cDisplayClass1_2 = this;
                        // ISSUE: reference to a compiler-generated field
                        string str2 = cDisplayClass1_2.ret + "\r\n\r\n" + Utils.GenerateReportFromExceptionCompact(ex) + "\r\n\r\n";
                        // ISSUE: reference to a compiler-generated field
                        cDisplayClass1_2.ret = str2;
                    }
                }
            }));
            errorsAdded = errors;
            return(ret);
        }
Exemple #9
0
        public static string TestBlankExtension(ScreenManager screenMan, out int errorsAdded)
        {
            int    errors = 0;
            string ret    = "";
            OS     os;

            try
            {
                os = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestBlankExtension", screenMan);
            }
            catch (Exception ex)
            {
                errorsAdded = 1;
                return("\nError generating blank extension:\n" + Utils.GenerateReportFromException(ex));
            }
            ExtensionTests.TestOSForBlankSession((object)os, out ret, out errors);
            screenMan.RemoveScreen((GameScreen)os);
            ExtensionTests.CompleteExtensiontesting();
            errorsAdded = errors;
            return(ret);
        }
Exemple #10
0
        public static string TestAcademicDatabase(ScreenManager screenMan, out int errorsAdded)
        {
            int    num = 0;
            string str = "";
            OS     os1 = (OS)ExtensionTests.SetupOSForTests("Content/Tests/IntroExtension", screenMan);

            if (os1.netMap.academicDatabase == null)
            {
                ++num;
                str += "\nNo Academic Database Detected where there should be one!";
            }
            os1.threadedSaveExecute(false);
            screenMan.RemoveScreen((GameScreen)os1);
            OS os2 = (OS)null;

            OS.WillLoadSave = true;
            OS os3 = (OS)ExtensionTests.SetupOSForTests("Content/Tests/IntroExtension", screenMan);

            if (os3.netMap.academicDatabase == null)
            {
                ++num;
                str += "\nNo Academic Database Detected after save/load!";
            }
            screenMan.RemoveScreen((GameScreen)os3);
            os2             = (OS)null;
            OS.WillLoadSave = false;
            OS os4 = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestBlankExtension", screenMan);

            if (os4.netMap.academicDatabase != null)
            {
                ++num;
                str += "\nAcademic database was created in empty session!!";
            }
            screenMan.RemoveScreen((GameScreen)os4);
            ExtensionTests.CompleteExtensiontesting();
            errorsAdded = num;
            return(str);
        }
Exemple #11
0
        public static string TestExtensionCustomFactionsActions(ScreenManager screenMan, out int errorsAdded)
        {
            int    errorsAdded1 = 0;
            string str1         = "";
            OS     os1          = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestExtension", screenMan);
            string str2         = str1 + ExtensionTests.TestExtensionsFactions(os1.allFactions, out errorsAdded1);
            Folder folder       = Programs.getComputer(os1, "linkNode1").files.root.searchForFolder("bin");

            if (folder.searchForFile("FTPBounce.exe") != null)
            {
                ++errorsAdded1;
                str2 += "\nFile somehow already on target system for faction test";
            }
            if (os1.currentFaction != null)
            {
                ++errorsAdded1;
                str2 += "\nFaction does not start as null";
            }
            ComputerLoader.loadMission(Utils.GetFileLoadPrefix() + "Missions/FactionTestMission0.xml", false);
            if (os1.currentFaction.idName != "autoTestFaction")
            {
                ++errorsAdded1;
                str2 += "\nLoading mission with start function to set player faction does not load faction correctly";
            }
            if (os1.currentFaction.playerValue != 0)
            {
                ++errorsAdded1;
                str2 = str2 + "\nPlayer faction not expected before mission completion. Expected 0, got " + (object)os1.currentFaction.playerValue;
            }
            os1.currentMission.finish();
            if (os1.currentFaction.playerValue != 5)
            {
                ++errorsAdded1;
                str2 = str2 + "\nPlayer faction not expected after mission completion. Expected 5, got " + (object)os1.currentFaction.playerValue;
            }
            FileEntry fileEntry = folder.searchForFile("FTPBounce.exe");

            if (fileEntry == null)
            {
                ++errorsAdded1;
                str2 += "\nFile not added correctly in response to faction progression";
            }
            else if (fileEntry.data != PortExploits.crackExeData[21])
            {
                ++errorsAdded1;
                str2 += "\nFile added through faction system data not correctly filtered.";
            }
            os1.threadedSaveExecute(false);
            screenMan.RemoveScreen((GameScreen)os1);
            OS.WillLoadSave = true;
            OS     os2  = (OS)ExtensionTests.SetupOSForTests("Content/Tests/TestExtension", screenMan);
            string str3 = str2 + ExtensionTests.TestExtensionsFactions(os2.allFactions, out errorsAdded1);

            if (os2.currentFaction.idName != "autoTestFaction")
            {
                ++errorsAdded1;
                str3 += "\nFaction not set correctly after load";
            }
            CustomFaction currentFaction = os2.currentFaction as CustomFaction;

            if (currentFaction == null)
            {
                ++errorsAdded1;
                str3 += "\nFaction is not set to the correct type after load";
            }
            if (currentFaction.CustomActions.Count != 1)
            {
                ++errorsAdded1;
                str3 += "\nFaction has incorrect number of remaining custom actions after load";
            }
            if (os2.currentFaction.playerValue != 5)
            {
                ++errorsAdded1;
                str3 = str3 + "\nPlayer faction value not set correctly after load. Expected 5, got " + (object)os2.currentFaction.playerValue;
            }
            os2.currentMission.finish();
            if (Programs.getComputer(os2, "linkNode1").files.root.searchForFolder("bin").searchForFile("SecondTestFile.txt") == null)
            {
                ++errorsAdded1;
                str3 += "\nSecond File not added correctly in response to faction progression";
            }
            screenMan.RemoveScreen((GameScreen)os2);
            ExtensionTests.CompleteExtensiontesting();
            errorsAdded = errorsAdded1;
            return(str3);
        }
Exemple #12
0
        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("");
        }