Esempio n. 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"))));
        }
Esempio n. 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))));
        }
Esempio n. 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}"))));
        }
Esempio n. 4
0
 private void VerifyOutput(string expected)
 {
     ConsoleMock.Verify(x => x.WriteLine(StringCalculator.OutputPrefix + expected));
 }
Esempio n. 5
0
 public void GivenEmptyInputPrgramExits()
 {
     ConsoleMock.SetupSequence(x => x.Readline()).Returns("");
     RunMain("1");
     ConsoleMock.Verify(x => x.Readline(), Times.Exactly(1));
 }
Esempio n. 6
0
 public void AppAlwaysChecksForAnotherInput()
 {
     RunMain("1");
     ConsoleMock.Verify(x => x.Readline());
 }
Esempio n. 7
0
 public void AppAlwaysPromptsForAnotherInput()
 {
     RunMain("1");
     ConsoleMock.Verify(x => x.WriteLine("Another input please"));
 }