public void CharacterSearchBackward() { TestSetup(KeyMode.Cmd); Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.ShiftF3, '|', CheckThat(() => AssertCursorLeftIs(12)), _.ShiftF3, '|', CheckThat(() => AssertCursorLeftIs(5)))); TestSetup(KeyMode.Emacs); Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.CtrlAltRBracket, '|', CheckThat(() => AssertCursorLeftIs(12)), _.CtrlAltRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)), _.Home, _.AltMinus, _.Alt2, _.CtrlAltRBracket, '|', CheckThat(() => AssertCursorLeftIs(12)), _.End, _.Alt2, _.CtrlAltRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)))); TestMustDing("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.CtrlAltRBracket, 'z')); int i = 0; TestSetup(KeyMode.Cmd, new KeyHandler("Ctrl+z", (key, count) => PSConsoleReadLine.CharacterSearchBackward(null, i++ == 0 ? (object)'|' : "|"))); Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.CtrlZ, CheckThat(() => AssertCursorLeftIs(12)), _.CtrlZ, CheckThat(() => AssertCursorLeftIs(5)))); }
public void CharacterSearchBackwardApi() { int i = 0; TestSetup(KeyMode.Cmd, new KeyHandler("Ctrl+z", (key, count) => PSConsoleReadLine.CharacterSearchBackward(null, i++ == 0 ? (object)'|' : "|"))); Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.Ctrl_z, CheckThat(() => AssertCursorLeftIs(12)), _.Ctrl_z, CheckThat(() => AssertCursorLeftIs(5)))); }
public void TestCharacterSearchBackward() { TestSetup(KeyMode.Cmd); Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.ShiftF3, '|', CheckThat(() => AssertCursorLeftIs(12)), _.ShiftF3, '|', CheckThat(() => AssertCursorLeftIs(5)))); TestSetup(KeyMode.Emacs); Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.AltCtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(12)), _.AltCtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)), _.Home, _.AltMinus, _.Alt2, _.AltCtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(12)), _.End, _.Alt2, _.AltCtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)))); using (ShimsContext.Create()) { bool ding = false; PSConsoleUtilities.Fakes.ShimPSConsoleReadLine.Ding = () => ding = true; Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.AltCtrlRBracket, 'z', CheckThat(() => Assert.IsTrue(ding)))); } int i = 0; TestSetup(KeyMode.Cmd, new KeyHandler("Ctrl+z", (key, count) => PSConsoleReadLine.CharacterSearchBackward(null, i++ == 0 ? (object)'|' : "|"))); Test("cmd1 | cmd2 | cmd3", Keys( "cmd1 | cmd2 | cmd3", _.CtrlZ, CheckThat(() => AssertCursorLeftIs(12)), _.CtrlZ, CheckThat(() => AssertCursorLeftIs(5)))); }