Beispiel #1
0
        private bool PlaybackSingleCommand()
        {
            if (null == assertions)
            {
                assertions = new List <AssertionResult>();
            }

            commandIndex = commandIndex + 1;
            if (commandIndex >= editorCommands.Count)
            {
                if (xmlTestFiles.Count > 1) // Multi-playback mode.
                {
                    if (null == testResults)
                    {
                        testResults = new List <AutomationResult>();
                    }

                    testResults.Add(new AutomationResult(currentTestName, assertions));
                }

                playbackComplete = true;
                assertions       = null;
                return(false); // Done playing back.
            }

            TextEditorCommand command = editorCommands[commandIndex];
            int commandInterval       = (int)command.IntervalTime;

            commandInterval        = ((commandInterval > 220) ? 220 : commandInterval);
            playbackTimer.Interval = TimeSpan.FromMilliseconds(commandInterval);
            bool result = textEditorCore.PlaybackCommand(command);

            PlaybackVisualizer.Instance.SetCurrentCommand(command);

            switch (command.MethodName)
            {
            case TextEditorCommand.Method.LoadScriptFromFile:
                if (!result)
                {
                    assertions = new List <AssertionResult>();
                    assertions.Add(new AssertionResult("Fail", "0", "Invalid path! Cannot load script!"));
                    if (null == testResults)
                    {
                        testResults = new List <AutomationResult>();
                    }
                    testResults.Add(new AutomationResult(currentTestName, assertions));
                    playbackComplete = true;
                    assertions       = null;
                    TextEditorCommand closeScriptCommand = new TextEditorCommand(TextEditorCommand.Method.CloseScript);
                    closeScriptCommand.AppendArgument(0);
                    int  scriptCount       = textEditorControl.ScriptTabControl.TabCount;
                    bool closeScriptResult = textEditorCore.PlaybackCommand(closeScriptCommand);
                    while (--scriptCount != 0)
                    {
                        closeScriptResult = textEditorCore.PlaybackCommand(closeScriptCommand);
                    }
                    textEditorControl.ScriptTabControl.CloseAllTabs();
                    textEditorControl.ShowTabControls(false);

                    return(false);    // Exit playback.
                }
                textEditorControl.SetupTabInternal(command.Arguments[0] as string);
                break;

            case TextEditorCommand.Method.CreateNewScript:
                textEditorControl.SetupTabInternal(null);
                break;

            case TextEditorCommand.Method.CloseScript:
                textEditorControl.PlaybackCloseTab((int)command.Arguments[0]);
                break;

            case TextEditorCommand.Method.ChangeScript:
                textEditorControl.PlaybackSwitchTab((int)command.Arguments[0]);
                break;

            case TextEditorCommand.Method.Step:
                textEditorControl.UpdateUiForStepNext(result);
                break;

            case TextEditorCommand.Method.Run:
                textEditorControl.UpdateUiForRun(result);
                break;

            case TextEditorCommand.Method.Stop:
                textEditorControl.UpdateUiForStop(result);
                break;
            }

            textEditorControl.UpdateScriptDisplay(Solution.Current.ActiveScript);
            textEditorControl.UpdateCaretPosition();

            if (null != command.Asserts)
            {
                DoAssertions(command.Asserts);
            }

            return(true);
        }