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

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            cut.GetNumber(promptMessage, 1, 2, "exit", 0);

            // Assert
            _mockConsole.Verify(v => v.WriteLine(promptMessage), Times.Exactly(usageCount), message);
        }
Exemplo n.º 2
0
        public void Overload1_ReturnsCorrectValue(string input, int?expectedOutput)
        {
            // Arrange
            _mockConsole.Setup(s => s.ReadLine()).Returns(input);

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            int?actualOutput = cut.GetNumber(null, 1);


            // Assert
            Assert.AreEqual(expectedOutput, actualOutput);
        }
Exemplo n.º 3
0
        public void Overload2_ReturnsCorrectValue(string input, int?expectedOutput, string message)
        {
            // Arrange
            _mockConsole.SetupSequence(s => s.ReadLine())
            .Returns(input).Returns("exit");

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            int?actualOutput = cut.GetNumber(null, -20, 20, "exit", -100);


            // Assert
            Assert.AreEqual(expectedOutput, actualOutput, message);
        }
Exemplo n.º 4
0
        public void Overload1_WhenOrderedToPromptTwiceItDoes()
        {
            // Arrange
            _mockConsole.SetupSequence(s => s.ReadLine())
            .Returns("Not_a_number").Returns("still_not_a_number");

            var cut = new PromptHelper(_mockConsole.Object);

            // Act
            int?actualOutput = cut.GetNumber(null, 2);


            // Assert
            _mockConsole.Verify(v => v.ReadLine(), Times.Exactly(2));
        }