public void PrintAdditionalInfo(QuadraticEquation equation) { String info = equation.ToString() + "\nRoots:"; equation.GetSolutions().ToList().ForEach((solution) => { info += $"{solution:F3}, "; }); Console.WriteLine(info); }
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); }
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); }