コード例 #1
0
        public void AlgorithmInterpreterStepOverBreakpoint()
        {
            var program = CreateBasicProgramWithTwoBreakpoints();
            var algorithmInterpreter = new AlgorithmInterpreter(program);

            algorithmInterpreter.StartAsync(debugMode: true);

            Task.Delay(TimeSpan.FromSeconds(2)).Wait();

            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[4].State, AlgorithmInterpreterState.PauseBreakpoint);
            Assert.AreEqual(algorithmInterpreter.DebugInfo.CallStackService.CallStacks.First().Stack.First().Variables.Count, 0);

            algorithmInterpreter.StepOver();

            Task.Delay(TimeSpan.FromSeconds(2)).Wait();

            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[7].State, AlgorithmInterpreterState.PauseBreakpoint);
            Assert.AreEqual(algorithmInterpreter.DebugInfo.CallStackService.CallStacks.First().Stack.First().Variables[0].Name, "result");
            Assert.AreEqual(algorithmInterpreter.DebugInfo.CallStackService.CallStacks.First().Stack.First().Variables[0].Value, null);

            algorithmInterpreter.StepOver();

            Task.Delay(TimeSpan.FromSeconds(2)).Wait();

            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[22].State, AlgorithmInterpreterState.PauseBreakpoint);
            Assert.AreEqual(algorithmInterpreter.DebugInfo.CallStackService.CallStacks.First().Stack.First().Variables[0].Name, "num");
            Assert.AreEqual(algorithmInterpreter.DebugInfo.CallStackService.CallStacks.First().Stack.First().Variables[0].Value, (long)20);

            algorithmInterpreter.Resume();

            Task.Delay(TimeSpan.FromSeconds(2)).Wait();

            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[0].State, AlgorithmInterpreterState.Ready);
            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[1].State, AlgorithmInterpreterState.Preparing);
            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[2].State, AlgorithmInterpreterState.Running);
            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[3].State, AlgorithmInterpreterState.Log);
            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[28].LogMessage, "(Main) Return : '20' (type:System.Int32)");
            Assert.AreEqual(algorithmInterpreter.StateChangeHistory[29].State, AlgorithmInterpreterState.Stopped);
            Assert.AreEqual(algorithmInterpreter.State, AlgorithmInterpreterState.Stopped);

            AlgorithmInterpreter_Test.RunProgramWithoutDebug(program);
        }