public void PrintAdditionalInfo(QuadraticEquation equation)
        {
            String info = equation.ToString() + "\nRoots:";

            equation.GetSolutions().ToList().ForEach((solution) => { info += $"{solution:F3}, "; });
            Console.WriteLine(info);
        }
Esempio n. 2
0
        public void ComplexQuadraticEquation(double a, double b, double c, string stringForm, double firstReal, double firstImaginary, double secondReal, double secondImaginary)
        {
            var equation = new QuadraticEquation(a, b, c);

            equation.ToString().Should().Be(stringForm);
            var solution = equation.Solution();

            solution.IsRealRoots.Should().BeFalse();
            solution.ComplexRoots.FirstRoot.Should().Be(new Complex(firstReal, firstImaginary));
            solution.ComplexRoots.SecondRoot.Should().Be(new Complex(secondReal, secondImaginary));
            Assert.ThrowsException <ArgumentException>(() => solution.RealRoots);
        }
Esempio n. 3
0
        public void RealQuadraticEquation(double a, double b, double c, string stringForm, double firstRoot, double secondRoot)
        {
            var equation = new QuadraticEquation(a, b, c);

            equation.ToString().Should().Be(stringForm);
            var solution = equation.Solution();

            solution.IsRealRoots.Should().BeTrue();
            solution.RealRoots.FirstRoot.Should().Be(firstRoot);
            solution.RealRoots.SecondRoot.Should().Be(secondRoot);
            Assert.ThrowsException <ArgumentException>(() => solution.ComplexRoots);
        }