public void SetUpFixture() { MockTextEditor textEditor = new MockTextEditor(); using (pythonConsole = new PythonConsole(textEditor, null)) { textEditor.RaiseKeyPressEvent('a'); textEditor.RaiseKeyPressEvent('='); textEditor.RaiseKeyPressEvent('1'); lineAvailableBeforeFirstEnterKey = pythonConsole.IsLineAvailable; textEditor.RaiseDialogKeyPressEvent(Keys.Enter); lineAvailableAfterFirstEnterKey = pythonConsole.IsLineAvailable; textEditor.RaiseKeyPressEvent('b'); textEditor.RaiseKeyPressEvent('='); textEditor.RaiseKeyPressEvent('2'); textEditor.RaiseDialogKeyPressEvent(Keys.Enter); Thread t = new Thread(ReadLinesOnSeparateThread); t.Start(); int sleepInterval = 20; int currentWait = 0; int maxWait = 2000; while (line2 == null && currentWait < maxWait) { Thread.Sleep(sleepInterval); currentWait += sleepInterval; } lineAvailableAtEnd = pythonConsole.IsLineAvailable; } }
public void HomeKeyPressedWhenNoUserTextInConsole() { textEditor.RaiseDialogKeyPressEvent(Keys.Home); int expectedColumn = prompt.Length; Assert.AreEqual(expectedColumn, textEditor.Column); }
public void EnterKeyDoesNotBreakUpExistingLine() { textEditor.RaiseKeyPressEvent('a'); textEditor.RaiseKeyPressEvent('b'); textEditor.SelectionStart = 1 + prompt.Length; textEditor.Column = 1 + prompt.Length; textEditor.RaiseDialogKeyPressEvent(Keys.Enter); Assert.AreEqual(">>> ab\r\n", textEditor.Text); }
public void Init() { textEditor = new MockTextEditor(); pythonConsole = new PythonConsole(textEditor, null); pythonConsole.Write(prompt, Style.Prompt); textEditor.RaiseKeyPressEvent('a'); textEditor.RaiseDialogKeyPressEvent(Keys.Enter); pythonConsole.Write(prompt, Style.Prompt); textEditor.RaiseKeyPressEvent('b'); textEditor.RaiseKeyPressEvent('c'); textEditor.RaiseDialogKeyPressEvent(Keys.Enter); pythonConsole.Write(prompt, Style.Prompt); }
public void Init() { mockTextEditor = new MockTextEditor(); pythonConsole = new PythonConsole(mockTextEditor, null); autoIndentSize = initialAutoIndentSize; Thread thread = new Thread(ReadLineFromConsoleOnDifferentThread); thread.Start(); int sleepInterval = 10; int maxWait = 2000; int currentWait = 0; while (mockTextEditor.Text.Length < autoIndentSize && currentWait < maxWait) { Thread.Sleep(sleepInterval); currentWait += sleepInterval; } raiseKeyPressEvent = mockTextEditor.RaiseKeyPressEvent('a'); raiseDialogKeyPressEvent = mockTextEditor.RaiseDialogKeyPressEvent(Keys.Enter); currentWait = 0; while (mockTextEditor.Text.Length < autoIndentSize + 2 && currentWait < maxWait) { Thread.Sleep(10); currentWait += sleepInterval; } thread.Join(2000); }
public void AddOneLine() { textEditor.RaiseKeyPressEvent('a'); textEditor.RaiseDialogKeyPressEvent(Keys.Enter); string[] expectedLines = new string[] { "a" }; Assert.AreEqual(expectedLines, pythonConsole.GetUnreadLines()); Assert.IsTrue(pythonConsole.IsLineAvailable); }
public void NoTextWrittenWhenAutoIndentSizeIsZero() { MockTextEditor textEditor = new MockTextEditor(); PythonConsole console = new PythonConsole(textEditor, null); textEditor.RaiseKeyPressEvent('a'); textEditor.RaiseDialogKeyPressEvent(Keys.Enter); textEditor.IsWriteCalled = false; console.ReadLine(0); Assert.IsFalse(textEditor.IsWriteCalled); }
public void LeftArrowThenInsertNewCharacterInsertsText() { textEditor.RaiseKeyPressEvent('a'); textEditor.RaiseKeyPressEvent('b'); textEditor.RaiseDialogKeyPressEvent(Keys.Left); textEditor.RaiseKeyPressEvent('c'); Assert.AreEqual("acb", console.GetCurrentLine()); }
public void UpKeyDoesNothing() { Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Up)); }
public void UpArrowKeyPressed() { Assert.IsTrue(textEditor.RaiseDialogKeyPressEvent(Keys.Up)); }