public void TestEndOfLine()
        {
            TestSetup(KeyMode.Cmd);

            var keys = Keys(
                new KeyWithValidation(_.End, () => AssertCursorLeftIs(0)),
                new KeyWithValidation(_.Enter)
            );
            var result = Test(keys); Assert.AreEqual("", result);

            TestSetup(KeyMode.Cmd);

            var width = Console.BufferWidth;
            var buffer = new StringBuilder();
            keys = new KeyWithValidation[width * 3];
            int i = 0;
            while (i < width)
            {
                keys[i++] = new KeyWithValidation(_.Space);
                buffer.Append(' ');
            }
            keys[i++] = new KeyWithValidation(_.Home, () => AssertCursorLeftIs(0));
            keys[i++] = new KeyWithValidation(_.End, () => AssertCursorLeftTopIs(0, 1));
            keys[i] = new KeyWithValidation(_.Enter);
            result = Test(keys); Assert.AreEqual(buffer.ToString(), result);

            for (int j = 0; j < 5; j++)
            {
                keys[i++] = new KeyWithValidation(_.Space);
                buffer.Append(' ');
            }
            keys[i++] = new KeyWithValidation(_.Home, () => AssertCursorLeftIs(0));
            keys[i++] = new KeyWithValidation(_.End, () => AssertCursorLeftTopIs(5, 1));
            keys[i] = new KeyWithValidation(_.Enter);
            result = Test(keys); Assert.AreEqual(buffer.ToString(), result);
        }
        private static string Test(KeyWithValidation[] keys, string prompt = null)
        {
            Console.CursorLeft = 0;
            Console.CursorTop = 0;
            SetPrompt(prompt);
            int index = 0;
            try
            {
                using (ShimsContext.Create())
                {
                    PSConsoleUtilities.Fakes.ShimPSConsoleReadLine.ReadKey = () => keys[index].Key;
                    PSConsoleUtilities.Fakes.ShimPSConsoleReadLine.PostKeyHandler = () =>
                    {
                        if (keys[index].Validator != null)
                        {
                            keys[index].Validator();
                        }
                        index++;
                    };
                    System.Management.Automation.Fakes.ShimCommandCompletion.CompleteInputStringInt32HashtablePowerShell =
                        MockedCompleteInput;

                    return PSConsoleReadLine.ReadLine();
                }
            }
            catch (CancelReadLineException)
            {
                return null;
            }
        }