Esempio n. 1
0
        public void TestSetPersistOption()
        {
            Assert.AreEqual(DefaultCommands.Get | DefaultCommands.Set | DefaultCommands.Help, DefaultCommands.Default);
            TestCommands       cmds = new TestCommands();
            CommandInterpreter ci   = new CommandInterpreter(cmds);

            cmds.OtherData = 42;
            Assert.AreEqual("42", Capture(ci, "GET Other"));
            cmds.SomeData = "one-two-three";
            Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"));

            string options = Capture(ci, "SET");

            cmds.OtherData = 0;
            cmds.SomeData  = String.Empty;
            Assert.AreEqual("0", Capture(ci, "GET Other"));
            Assert.AreEqual(String.Empty, Capture(ci, "GET SomeData"));

            TextReader input = Console.In;

            try
            {
                Console.SetIn(new StringReader(options));//feed the output of SET back to SET
                ci.Run("SET", "/readInput");
            }
            finally { Console.SetIn(input); }

            //should now be restored
            Assert.AreEqual("42", Capture(ci, "GET Other"));
            Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"));
        }
Esempio n. 2
0
    public string GetCommands(string strSearch)
    {
        strSearch = strSearch.ToUpper();
        string       strResult = "";
        TestCommands tc        = new TestCommands();
        int          i         = 0;

        string[] arrTests = Regex.Split(tc.CMD, "\r\n");
        foreach (string strTest in arrTests)
        {
            if (string.IsNullOrEmpty(strTest))
            {
                continue;
            }
            if (strTest.ToUpper().IndexOf(strSearch) >= 0)
            {
                string strCoolText = strTest.Replace(strSearch, "<b>" + strSearch + "</b>");
                strCoolText = strCoolText.Replace(strSearch.ToLower(), "<b>" + strSearch.ToLower() + "</b>");
                strResult  += "<tr><td>" + strCoolText + "</td><td><a title=\"Add test\" style=\"color: Blue; cursor: pointer;\" onclick=\"AddTest('" + strTest.Replace('"', '`') + "');\"> Add</a></td></tr> ";
                i++;
            }
        }
        if (i == 0)
        {
            strResult = "Please click <a href=\"commands.aspx\" >here</a> if you need to add tests";
        }
        else
        {
            strResult = "<table width='100%' border=0>" + strResult + "</table>";
        }
        strResult = "<input align='right' src='IMAGES/power.GIF' style='border-width:0px;' type='image'  onclick=\"Div_Off()\" >" + strResult;
        return(strResult);
    }
Esempio n. 3
0
        public async Task TestGit()
        {
            foreach (TestRepo repo in Factory.TestGit.Values)
            {
                ICommandInput commandInput = new TestCommands(repo.RepoPath);
                IRepoControl  repoControl  = new Git();
                Assert.AreEqual(true, repoControl.Exists(commandInput));
                File.WriteAllText(repo.TestFilePath, $"Last Tested {DateTime.UtcNow.ToString()}\n{DateTime.UtcNow.Ticks}");
                await repoControl.CommitAsync(commandInput, "Unit Test");

                Assert.AreEqual(RepoStatus.CommitSucceeded, repoControl.Status);
            }
        }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         LoadText();
     }
     else
     {
         TestCommands tc = new TestCommands()
         {
             CMD = commandstext.InnerText
         };
         tc.Store();
         LoadText();
     }
 }
Esempio n. 5
0
    private void FixedUpdate()
    {
        DarkRiftAPI.Recieve();
        //Adjust the simulation rate based on how many frames in advance we have
        //This prevents lag stutters and promotes responsiveness
        //If we have 0 frames ahead, we cannot go ahead (hence the if statement)
        //ForeSight代表还有多少数据帧没有被执行
        if (ForeSight > 0)
        {
            float NewSimRate = (TargetSimulationRate * 1.1f) - (ForeSight * TargetSimulationRate * .1f);
            if (NewSimRate < TargetSimulationRate / 2)            //相当于数据帧缓存超过6那么就加速一倍执行fixedupdate
            {
                NewSimRate  = TargetSimulationRate / 2;
                DoVisualize = false;
            }
            else
            {
                DoVisualize = true;
            }
            Time.fixedDeltaTime = NewSimRate;
            ForeSight--;

            //Get our current frame
            Frame CurrentFrame = Frames [_StepCount];
            //Get the commands of our current frame and execute them
            List <Command> CurrentCommands = Command.Deserialize(CurrentFrame._Data);
            foreach (Command com in CurrentCommands)
            {
                //Executes the command...
                //Explore to TestCommands.cs to find the game logic behind commands
                TestCommands.Execute(com);
            }

            //Spawns a few objects in the beginning
            if (_StepCount == 0)
            {
                TestSpawn();
            }

            //Simulate the physics
            DPhysicsManager.Simulate();

            //Increase our step and advance forward in time
            _StepCount++;
        }
    }
Esempio n. 6
0
    protected void LoadText()
    {
        TestCommands tc = new TestCommands();

        commandstext.InnerText = tc.CMD;
    }