コード例 #1
0
        private static void ScreenFillHelper(CmdApp app, ViewportArea area, IntPtr hConsole)
        {
            Log.Comment("Fill screen with junk");
            app.UIRoot.SendKeys(Keys.Shift + "`" + Keys.Shift);

            Globals.WaitForTimeout(); // give the buffer time to fill.

            GetExpectedChar expectedCharAlgorithm = (int rowId, int colId, int height, int width) =>
            {
                // For the very last bottom right corner character, it should be space. Every other character is a Z when filled.
                if (rowId == (height - 1) && colId == (width - 1))
                {
                    return(' ');
                }
                else
                {
                    return('Z');
                }
            };

            BufferVerificationHelper(app, area, hConsole, expectedCharAlgorithm);
        }
コード例 #2
0
        private static void BufferVerificationHelper(CmdApp app, ViewportArea area, IntPtr hConsole, GetExpectedChar expectedCharAlgorithm)
        {
            WinCon.SMALL_RECT    viewport    = app.GetViewport(hConsole);
            Rectangle            selectRect  = new Rectangle(viewport.Left, viewport.Top, viewport.Width, viewport.Height);
            IEnumerable <string> scrapedText = area.GetLinesInRectangle(hConsole, selectRect);

            Verify.AreEqual(viewport.Height, scrapedText.Count(), "Verify the rows scraped is equal to the entire viewport height.");

            bool isValidState = true;

            string[] rows = scrapedText.ToArray();
            for (int i = 0; i < rows.Length; i++)
            {
                for (int j = 0; j < viewport.Width; j++)
                {
                    char actual   = rows[i][j];
                    char expected = expectedCharAlgorithm(i, j, rows.Length, viewport.Width);

                    isValidState = actual == expected;

                    if (!isValidState)
                    {
                        Verify.Fail(string.Format("Text buffer verification failed at Row: {0} Col: {1} Expected: '{2}' Actual: '{3}'", i, j, expected, actual));
                        break;
                    }
                }

                if (!isValidState)
                {
                    break;
                }
            }
        }