void VerifyScroll(CmdApp app, ScrollDir dir, int clicks) { WinCon.CONSOLE_SCREEN_BUFFER_INFO_EX beforeScroll; WinCon.CONSOLE_SCREEN_BUFFER_INFO_EX afterScroll; int deltaActual; int deltaExpected; beforeScroll = app.GetScreenBufferInfo(); switch (dir) { case ScrollDir.Vertical: app.ScrollWindow(clicks); break; case ScrollDir.Horizontal: app.HScrollWindow(clicks); break; default: throw new NotSupportedException(); } // Give the window message a moment to take effect. Globals.WaitForTimeout(); switch (dir) { case ScrollDir.Vertical: deltaExpected = clicks * app.GetRowsPerScroll(); break; case ScrollDir.Horizontal: deltaExpected = clicks * app.GetColsPerScroll(); break; default: throw new NotSupportedException(); } afterScroll = app.GetScreenBufferInfo(); switch (dir) { case ScrollDir.Vertical: // Scrolling "negative" vertically is pulling the wheel downward which makes the lines move down. // This means that if you scroll down from the top, before = 0 and after = 3. 0 - 3 = -3. // The - sign of the delta here then aligns with the down = negative rule. deltaActual = beforeScroll.srWindow.Top - afterScroll.srWindow.Top; break; case ScrollDir.Horizontal: // Scrolling "negative" horizontally is pushing the wheel left which makes lines move left. // This means that if you scroll left, before = 3 and after = 0. 0 - 3 = -3. // The - sign of the delta here then aligns with the left = negative rule. deltaActual = afterScroll.srWindow.Left - beforeScroll.srWindow.Left; break; default: throw new NotSupportedException(); } Verify.AreEqual(deltaExpected, deltaActual); }