public void Write_WriteErrorWhenScrollToEndWhenTextWrittenIsTrue_TextEditorIsScrolled()
        {
            TestableScriptingConsole.ScrollToEndWhenTextWritten = true;
            TestableScriptingConsole.Write("a", ScriptingStyle.Error);

            Assert.IsTrue(FakeConsoleTextEditor.IsScrollToEndCalled);
        }
Example #2
0
 public void CanMoveOutOfPromptRegionWithUpCursorKey()
 {
     FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
     TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);
     FakeConsoleTextEditor.Column = 0;
     Assert.IsFalse(FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up));
 }
        public void Write_WritePromptWhenScrollToEndWhenTextWrittenIsFalse_TextEditorIsNotScrolled()
        {
            TestableScriptingConsole.ScrollToEndWhenTextWritten = false;
            TestableScriptingConsole.Write("a", ScriptingStyle.Prompt);

            Assert.IsFalse(FakeConsoleTextEditor.IsScrollToEndCalled);
        }
Example #4
0
 public void CanMoveInReadOnlyRegionWithDownCursorKey()
 {
     FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
     TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);
     FakeConsoleTextEditor.Column = 0;
     FakeConsoleTextEditor.Line   = 0;
     Assert.IsFalse(FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Down));
 }
        public void Clear_TextEditorHasText_RemovesAllText()
        {
            TestableScriptingConsole.Write("a", ScriptingStyle.Prompt);
            TestableScriptingConsole.Clear();

            bool cleared = FakeConsoleTextEditor.IsClearCalled;

            Assert.IsTrue(cleared);
        }
Example #6
0
        public void Init()
        {
            base.CreateConsole();
            TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);

            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.A);
            FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
            TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);
            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.B);
            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.OemPeriod);
        }
        public void Write_SendTextCalledButNoPromptWritten_WritesOutSavedText()
        {
            base.CreateConsole();
            TestableScriptingConsole.SendText("test");

            TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);
            string text = FakeConsoleTextEditor.TextPassedToAppend;

            string expectedText = "test";

            Assert.AreEqual(expectedText, text);
        }
        public void Write_CalledTwiceAfterSendLineCalledButNoPromptWritten_WritesOutSavedSendLineTextOnlyOnce()
        {
            base.CreateConsole();
            TestableScriptingConsole.SendLine("test");

            TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);
            TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);

            string text = FakeConsoleTextEditor.Text;

            string expectedText =
                ">>> test\r\n" +
                ">>> ";

            Assert.AreEqual(expectedText, text);
        }
Example #9
0
        public void BackspaceOnPreviousLine()
        {
            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.A);
            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.B);
            FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);

            TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);

            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.C);

            // Move up a line with cursor.
            FakeConsoleTextEditor.Line = 0;

            Assert.IsTrue(FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Back));
            Assert.AreEqual("C", TestableScriptingConsole.GetCurrentLine());
        }
        public void PreviousLineIsReadOnlyAfterEnterPressed()
        {
            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.A);
            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.B);
            FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
            TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);

            // Move up a line with cursor.
            FakeConsoleTextEditor.Line = 0;
            FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.C);

            string expectedText =
                ">>> AB\r\n" +
                ">>> ";

            Assert.AreEqual(expectedText, FakeConsoleTextEditor.Text);
        }
        public void Write_SendTextCalledWithTwoLinesButNoPromptWrittenAndWriteCalledTwice_WritesOutSecondLineOfSavedText()
        {
            base.CreateConsole();
            string text =
                "first\r\n" +
                "second";

            TestableScriptingConsole.SendText(text);

            TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);
            TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);

            string textPassedToWrite = FakeConsoleTextEditor.TextPassedToAppend;
            string expectedText      = "second";

            Assert.AreEqual(expectedText, textPassedToWrite);
        }
Example #12
0
 public void Init()
 {
     base.CreateConsole();
     TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);
 }
Example #13
0
 public void WritePrompt()
 {
     TestableScriptingConsole.Write(">>> ", ScriptingStyle.Prompt);
 }
 public void Init()
 {
     console = new TestableScriptingConsole();
     console.Write(prompt, ScriptingStyle.Prompt);
     textEditor = console.FakeConsoleTextEditor;
 }
 public void Write_TwoWrites_BothWrittenToTextEditor()
 {
     TestableScriptingConsole.Write("a", ScriptingStyle.Out);
     TestableScriptingConsole.Write("b", ScriptingStyle.Out);
     Assert.AreEqual("ab", FakeConsoleTextEditor.Text);
 }