Пример #1
0
        void TestEquation(double a, double b, double c, params double[] expectedResult)
        {
            var result = QuadraticEquationsSolver.Solve(a, b, c);

            Assert.AreEqual(expectedResult.Length, result.Length);
            for (int i = 0; i < result.Length; i++)
            {
                Assert.AreEqual(expectedResult[i], result[i]);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var a        = double.Parse(Console.ReadLine());
            var b        = double.Parse(Console.ReadLine());
            var c        = double.Parse(Console.ReadLine());
            var solution = QuadraticEquationsSolver.Solve(a, b, c);

            Console.WriteLine(solution[0]);
            Console.WriteLine(solution[1]);
            Console.ReadKey();
        }
Пример #3
0
 public void FunctionalTest()
 {
     for (int i = 0; i < 100; i++)
     {
         var rnd    = new Random(i);
         var a      = rnd.NextDouble() * 10;
         var b      = rnd.NextDouble() * 10;
         var c      = rnd.NextDouble() * 10;
         var result = QuadraticEquationsSolver.Solve(a, b, c);
         foreach (var x in result)
         {
             Assert.AreEqual(0, a * x * x + b * x + c, 1e-10);
         }
     }
 }
Пример #4
0
        [TestMethod] // <= так нужно пометить метод, чтобы система тестирования поняла, что это тест.
        public void OrdinaryEquations()
        {
            // Arrange:
            var a = 1;
            var b = -3;
            var c = 2;

            //Act:
            var result = QuadraticEquationsSolver.Solve(a, b, c);

            //Assert:
            Assert.AreEqual(2, result.Length);
            Assert.AreEqual(2, result[0]);
            Assert.AreEqual(1, result[1]);
        }
Пример #5
0
        static void Main(string[] args)
        {
            var a        = double.Parse(Console.ReadLine());
            var b        = double.Parse(Console.ReadLine());
            var c        = double.Parse(Console.ReadLine());
            var solution = QuadraticEquationsSolver.Solve(a, b, c);

            if (solution.Length > 1)
            {
                Console.WriteLine(solution[0]);
            }
            if (solution.Length > 2)
            {
                Console.WriteLine(solution[1]);
            }
            else
            {
                Console.WriteLine("None");
            }

            Console.ReadKey();
        }