コード例 #1
0
        public void UnitTestSquareEquationService()
        {
            string path = @"C:\Users\overl\source\repos\TestSquareExample\TestSquareExample\SquareEquationContent.txt";
            SquareEquationService SquareEquationService = new SquareEquationService();

            List <SquareEquation> SquareEquation = SquareEquationService.CreateConnectionFile(path);

            Assert.NotEmpty(SquareEquation);
        }
コード例 #2
0
        public void UnitTestSolveDiscriminant()
        {
            SquareEquationService SquareEquationService = new SquareEquationService();

            double D = SquareEquationService.SolveDiscriminant(new SquareEquation {
                a = 1, b = 4, c = 1
            });

            Assert.Equal(D, 12.0);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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");
            }
        }