Beispiel #1
0
        public void Solve_WhenExpressionHasAllSolutions_ShouldWriteProperSolution(string expr)
        {
            //Arrange
            SetupSolver();

            //Act
            TestedSolver.Solve(new[] { expr });

            //Assert
            ConsoleMock
            .Verify(c => c.WriteLine(It.Is <string>(
                                         s => s.Contains("All real numbers"))));
        }
Beispiel #2
0
        public void Solve_WhenCalledWithInvalidExpression_ShouldWriteError(string expression, string errorMessage)
        {
            //Arrange
            SetupSolver();

            //Act
            TestedSolver.Solve(new[] { expression });

            //Assert
            ConsoleMock
            .Verify(c => c.WriteLine(It.Is <string>(
                                         s => s.Contains(errorMessage))));
        }
Beispiel #3
0
        public void Solve_WhenExpressionHasSingleRationalSolutionAndDegreeOne_ShouldWriteProperSolution(string expr,
                                                                                                        string x)
        {
            //Arrange
            SetupSolver();

            //Act
            TestedSolver.Solve(new[] { expr });

            //Assert
            ConsoleMock
            .Verify(c => c.WriteLine(It.Is <string>(
                                         s => s.Contains("Degree: 1"))));
            ConsoleMock
            .Verify(c => c.WriteLine(It.Is <string>(
                                         s => s.Contains($" = {x}"))));
        }
Beispiel #4
0
 private void VerifyOutput(string expected)
 {
     ConsoleMock.Verify(x => x.WriteLine(StringCalculator.OutputPrefix + expected));
 }
Beispiel #5
0
 public void GivenEmptyInputPrgramExits()
 {
     ConsoleMock.SetupSequence(x => x.Readline()).Returns("");
     RunMain("1");
     ConsoleMock.Verify(x => x.Readline(), Times.Exactly(1));
 }
Beispiel #6
0
 public void AppAlwaysChecksForAnotherInput()
 {
     RunMain("1");
     ConsoleMock.Verify(x => x.Readline());
 }
Beispiel #7
0
 public void AppAlwaysPromptsForAnotherInput()
 {
     RunMain("1");
     ConsoleMock.Verify(x => x.WriteLine("Another input please"));
 }