Exemplo n.º 1
0
        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}");
        }
Exemplo n.º 3
0
        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??"));
        }
Exemplo n.º 4
0
        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));
        }