1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Windows.Input;
6
using ICSharpCode.Scripting;
8
using ICSharpCode.Scripting.Tests.Utils;
10
namespace ICSharpCode.Scripting.Tests.Console
13
/// Tests that pressing the enter key in the middle of a typed in line in the console
14
/// leaves the line alone and moves the cursor to the next line. By default the text editor
15
/// will break the line and move the last part to the second line.
18
public class ScriptingConsoleEnterKeyTests : ScriptingConsoleTestsBase
20
string prompt = ">>> ";
26
TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);
29
public void EnterKeyDoesNotBreakUpExistingLine()
31
FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.A);
32
FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.B);
33
FakeConsoleTextEditor.SelectionStart = 1 + prompt.Length;
34
FakeConsoleTextEditor.Column = 1 + prompt.Length;
35
FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
37
Assert.AreEqual(">>> AB\r\n", FakeConsoleTextEditor.Text);
41
public void PreviousLineIsReadOnlyAfterEnterPressed()
43
FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.A);
44
FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.B);
45
FakeConsoleTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
46
TestableScriptingConsole.Write(prompt, ScriptingStyle.Prompt);
48
// Move up a line with cursor.
49
FakeConsoleTextEditor.Line = 0;
50
FakeConsoleTextEditor.RaisePreviewKeyDownEvent(Key.C);
55
Assert.AreEqual(expectedText, FakeConsoleTextEditor.Text);