Example #1
0
        public async void ShouldRenderErrorMessageAndRenderTheMenuAgainIfNumberEnteredIsNotANumber()
        {
            SetUpMenuSelectionThenQuit("12AlphaBravo");

            await ScreenManager.StartInputOutputLoop();

            VerifyMenuIsRendered(Twice);
            MockConsoleWrapper.Verify(x => x.WriteLineAsync("Selection is invalid.  Please select an option."));
        }
Example #2
0
        public async void ShouldRenderErrorMessageAndRenderTheMenuAgainIfNumberEnteredIsTooLarge()
        {
            SetUpMenuSelectionThenQuit("98324");

            await ScreenManager.StartInputOutputLoop();

            VerifyScreenIsCleared(Thrice);
            VerifyMenuIsRendered(Twice);
            MockConsoleWrapper.Verify(x => x.WriteLineAsync("Selection out of range.  Please select an option."));
        }
        public async void ShouldWaitForInputAtEachLineRendered()
        {
            MockConsoleWrapper.Setup(x => x.ReadLineAsync()).ReturnsAsync("abc");

            await Screen.Activated();

            for (var lineNumber = 0; lineNumber < DisplayNames.Count(); lineNumber++)
            {
                var topPosition = lineNumber;
                MockConsoleWrapper.Verify(x => x.SetCursorPosition(32, topPosition));
                MockConsoleWrapper.Verify(x => x.ReadLineAsync());
            }
        }
Example #4
0
        public async void ShouldRenderAnOptionForQuitting()
        {
            await ScreenManager.StartInputOutputLoop();

            MockConsoleWrapper.Verify(x => x.WriteLineAsync("99. Quit"), Times.Once);
        }
Example #5
0
 private void VerifyScreenIsCleared(int count)
 {
     MockConsoleWrapper.Verify(x => x.ClearScreen(), Times.Exactly(count));
 }
Example #6
0
 private void VerifyMenuIsRendered(int count)
 {
     MockConsoleWrapper.Verify(x => x.WriteLineAsync($"1. {ScreenNameOne}"), Times.Exactly(count));
     MockConsoleWrapper.Verify(x => x.WriteLineAsync($"2. {ScreenNameTwo}"), Times.Exactly(count));
     MockConsoleWrapper.Verify(x => x.WriteLineAsync($"3. {ScreenNameThree}"), Times.Exactly(count));
 }