Beispiel #1
0
        public void CharacterSearch()
        {
            TestSetup(KeyMode.Cmd);

            Test("cmd1 | cmd2 | cmd3", Keys(
                     "cmd1 | cmd2 | cmd3", _.Home,
                     _.F3, '|', CheckThat(() => AssertCursorLeftIs(5)),
                     _.F3, '|', CheckThat(() => AssertCursorLeftIs(12))));

            TestSetup(KeyMode.Emacs);

            Test("cmd1 | cmd2 | cmd3", Keys(
                     "cmd1 | cmd2 | cmd3", _.Home,
                     _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)),
                     _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(12)),
                     _.End,
                     _.AltMinus, _.Alt2, _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)),
                     _.Home,
                     _.Alt2, _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(12))));

            TestMustDing("cmd1 | cmd2 | cmd3", Keys(
                             "cmd1 | cmd2 | cmd3",
                             _.CtrlRBracket, 'z'));

            int i = 0;

            TestSetup(KeyMode.Cmd, new KeyHandler("Ctrl+z",
                                                  (key, count) => PSConsoleReadLine.CharacterSearch(null, i++ == 0 ? (object)'|' : "|")));

            Test("cmd1 | cmd2 | cmd3", Keys(
                     "cmd1 | cmd2 | cmd3",
                     _.Home,
                     _.CtrlZ, CheckThat(() => AssertCursorLeftIs(5)),
                     _.CtrlZ, CheckThat(() => AssertCursorLeftIs(12))));
        }
Beispiel #2
0
        public void CharacterSearchApi()
        {
            int i = 0;

            TestSetup(KeyMode.Cmd, new KeyHandler("Ctrl+z",
                                                  (key, count) => PSConsoleReadLine.CharacterSearch(null, i++ == 0 ? (object)'|' : "|")));

            Test("cmd1 | cmd2 | cmd3", Keys(
                     "cmd1 | cmd2 | cmd3",
                     _.Home,
                     _.Ctrl_z, CheckThat(() => AssertCursorLeftIs(5)),
                     _.Ctrl_z, CheckThat(() => AssertCursorLeftIs(12))));
        }
Beispiel #3
0
        public void TestCharacterSearch()
        {
            TestSetup(KeyMode.Cmd);

            Test("cmd1 | cmd2 | cmd3", Keys(
                     "cmd1 | cmd2 | cmd3", _.Home,
                     _.F3, '|', CheckThat(() => AssertCursorLeftIs(5)),
                     _.F3, '|', CheckThat(() => AssertCursorLeftIs(12))));

            TestSetup(KeyMode.Emacs);

            Test("cmd1 | cmd2 | cmd3", Keys(
                     "cmd1 | cmd2 | cmd3", _.Home,
                     _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)),
                     _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(12)),
                     _.End,
                     _.AltMinus, _.Alt2, _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(5)),
                     _.Home,
                     _.Alt2, _.CtrlRBracket, '|', CheckThat(() => AssertCursorLeftIs(12))));

            using (ShimsContext.Create())
            {
                bool ding = false;
                PSConsoleUtilities.Fakes.ShimPSConsoleReadLine.Ding =
                    () => ding = true;

                Test("cmd1 | cmd2 | cmd3", Keys(
                         "cmd1 | cmd2 | cmd3",
                         _.CtrlRBracket, 'z', CheckThat(() => Assert.IsTrue(ding))));
            }

            int i = 0;

            TestSetup(KeyMode.Cmd, new KeyHandler("Ctrl+z",
                                                  (key, count) => PSConsoleReadLine.CharacterSearch(null, i++ == 0 ? (object)'|' : "|")));

            Test("cmd1 | cmd2 | cmd3", Keys(
                     "cmd1 | cmd2 | cmd3",
                     _.Home,
                     _.CtrlZ, CheckThat(() => AssertCursorLeftIs(5)),
                     _.CtrlZ, CheckThat(() => AssertCursorLeftIs(12))));
        }