public void InputReturnsValue(string input) { var consoleMock = new ConsoleMockBuilder() .WithReadLineSequence(input) .Build(); var sut = new Input(consoleMock.Object); var result = sut.Ask("Question?"); Assert.That(result, Is.EqualTo(input)); }
public void AllKeysContinue([Values] ConsoleKey input) { var consoleMock = new ConsoleMockBuilder() .WithReadKeySequence(input) .Build(); var sut = new PressAnyKeyToContinue(consoleMock.Object); sut.Ask(); Assert.Pass($"Ask did not block when ReadKey returned {input}"); }
public bool Confirm(params char[] inputSequence) { if (!inputSequence.Any(input => input == 'Y' || input == 'n')) { Assert.Fail(@"Invalid input sequence for this test, there needs to be a Y or n. Otherwise the the test will hang"); } var consoleMock = new ConsoleMockBuilder() .WithReadKeySequence(inputSequence) .Build(); var sut = new Confirm(consoleMock.Object); return(sut.Ask("Test Question??")); }
public string Select(ConsoleKey[] inputSequence, string[] options) { if (!inputSequence.Contains(ConsoleKey.Enter)) { Assert.Fail(@"Invalid input sequence for this test, there needs to be a Enter. Otherwise the the test will hang"); } var consoleMock = new ConsoleMockBuilder() .WithReadKeySequence(inputSequence) .Build(); Select sut = new Select(consoleMock.Object); return(sut.Ask("Test Question??", options)); }