public void UnitTestSearchRootOne()
        {
            SquareEquationService SquareEquationService = new SquareEquationService();

            double Root = SquareEquationService.SearchRoot(new SquareEquation {
                a = 1, b = 2, c = 1
            });
            double RootTest = -1.0;

            Assert.Equal(Root, RootTest);
        }
        public void UnitTestSearchRootTwo()
        {
            SquareEquationService SquareEquationService = new SquareEquationService();

            double[] Root = SquareEquationService.SearchRoot(new SquareEquation {
                a = 1, b = 4, c = 1
            }, 12.0);
            double[] RootTest = { -0.2679491924311228, -3.732050807568877 };

            Assert.Equal(Root, RootTest);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            ISquareEquation       SquareEquation = new SquareEquationService();
            List <SquareEquation> SquareEquationsList;

            string path = @"C:\Users\overl\source\repos\TestSquareExample\TestSquareExample\SquareEquationContent.txt";
            double D;

            SquareEquationsList = SquareEquation.CreateConnectionFile(path);
            try
            {
                foreach (SquareEquation item in SquareEquationsList)
                {
                    D = SquareEquation.SolveDiscriminant(item);

                    if (D > 0)
                    {
                        double[] Root = SquareEquation.SearchRoot(item, D);
                        Console.WriteLine(Root[0] + " " + Root[1]);
                    }
                    else if (D == 0)
                    {
                        double Root = SquareEquation.SearchRoot(item);
                        Console.WriteLine(Root);
                    }
                    else
                    {
                        Console.WriteLine("Never to solve equation");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Empty");
            }
        }