public void ReadLineImplementation_UsesThePromptIfGivenOne(string promptMessage, int numberOfTimesPrompted, string message) { // Arrange _mockConsole.Setup(s => s.ReadLine()).Returns("n"); var cut = new PromptHelper(_mockConsole.Object); // Act cut.GetYorN(promptMessage, true); // Assert _mockConsole.Verify(v => v.WriteLine(promptMessage), Times.Exactly(numberOfTimesPrompted), message); }
public void ReadLineImplementation_ContinuesToPromptTillItGetsTheCorrectAnswer() { // Arrange _mockConsole.SetupSequence(s => s.ReadLine()) .Returns(" ").Returns("z").Returns("s").Returns("Y"); var cut = new PromptHelper(_mockConsole.Object); // Act var actualResult = cut.GetYorN("Shall I proceed?", true); // Assert Assert.IsTrue(actualResult); }
public void ReadKeyImplementation_ContinuesToPromptTillItGetsTheCorrectAnswer() { // Arrange _mockConsole.SetupSequence(s => s.ReadKey()) .Returns(new ConsoleKeyInfo(' ', ConsoleKey.Spacebar, false, false, false)) .Returns(new ConsoleKeyInfo('z', ConsoleKey.Z, false, false, false)) .Returns(new ConsoleKeyInfo('s', ConsoleKey.S, false, false, false)) .Returns(new ConsoleKeyInfo('Y', ConsoleKey.Y, true, false, false)); var cut = new PromptHelper(_mockConsole.Object); // Act var actualResult = cut.GetYorN("Shall I proceed?", false); // Assert Assert.IsTrue(actualResult); }