Esempio n. 1
0
        public void Overload2_UsesThePromptIfGivenOne(string promptMessage, int numberOfTimesPrompted, string message)
        {
            // Arrange
            _mockConsole.Setup(s => s.ReadLine()).Returns("n");

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            cut.GetText(promptMessage, true, true);

            // Assert
            _mockConsole.Verify(v => v.WriteLine(promptMessage), Times.Exactly(numberOfTimesPrompted), message);
        }
Esempio n. 2
0
        public void Overload2_ReturnsTheCorrectText(string input, bool acceptBlank, bool trimResult, string expectedText)
        {
            // Arrange
            _mockConsole.Setup(s => s.ReadLine()).Returns(input);

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            var actualText = cut.GetText(null, acceptBlank, trimResult);

            // Assert
            Assert.AreEqual(expectedText, actualText);
        }
Esempio n. 3
0
        public void Overload2_ContinuesToPromptIfTextCannotBeBlank()
        {
            // Arrange
            _mockConsole.SetupSequence(s => s.ReadLine())
            .Returns("").Returns((string)null).Returns("").Returns(" ").Returns(" JaMes ");

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            var actualText = cut.GetText(null, false, true);

            // Assert
            Assert.AreEqual("JaMes", actualText);
        }
Esempio n. 4
0
        public void Overload1_ContinuesToPromptTillItGetsTheCorrectAnswer()
        {
            // Arrange
            _mockConsole.SetupSequence(s => s.ReadLine())
            .Returns("jack").Returns((string)null).Returns("").Returns(" ").Returns("z").Returns("james").Returns("c");

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            var actualText = cut.GetText(null, true, "a", "b", "c");

            // Assert
            Assert.AreEqual("c", actualText);
        }