예제 #1
0
        static void Main(string[] args)
        {
            var selectionReaderEquations = new SelectionReaderEquations();
            var factory  = new FactoryReaderQuadraticEquations(selectionReaderEquations);
            var executor = new ExecutorQuadraticEquation();

            var processSolvingQuadraticEquations = new ProcessSolvingQuadraticEquations(executor, factory);

            try
            {
                processSolvingQuadraticEquations.Run();
            }
            catch (DirectoryNotFoundException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
            catch (InvalidDataFotParametersException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Неожиданное исключение:");
                Console.WriteLine(ex);
            }
            Console.WriteLine("Для заверщения нажмите Enter:");
            Console.ReadLine();
        }
        public CountSolutionsEquation Execute_OtherCorrectParameters_CorrectCountSolutions(double a, double b, double c)
        {
            // arrange
            var executor = new ExecutorQuadraticEquation();

            // act and assert
            return(executor.Execute(a, b, c).CountSolutions);
        }
 public void Ctor_DoesNotException()
 {
     // arrange, act and assert
     Assert.DoesNotThrow(() =>
     {
         _ = new ExecutorQuadraticEquation();
     });
 }
        public void Execute_OtherCorrectParameters_NotSolutions(double a, double b, double c)
        {
            // arrange
            var executor = new ExecutorQuadraticEquation();

            // act
            var solutions = executor.Execute(a, b, c);

            // assert
            Assert.AreEqual(CountSolutionsEquation.NOT_SOLUTION, solutions.CountSolutions);
        }
        public double Execute_OtherCorrectParameters_CorrectOneSolution(double a, double b, double c)
        {
            // arrange
            var executor = new ExecutorQuadraticEquation();

            // act
            var solutions = executor.Execute(a, b, c);

            // assert
            Assert.AreEqual(CountSolutionsEquation.ONE, solutions.CountSolutions);
            return(solutions.X1);
        }
        public void Execute_OtherCorrectParameters_CorrectBothSolutions(double a, double b, double c, double expectedSolutionFirst, double expectedSolutionSecond)
        {
            // arrange
            var executor = new ExecutorQuadraticEquation();

            // act
            var solutions = executor.Execute(a, b, c);

            // assert
            Assert.AreEqual(CountSolutionsEquation.TWO, solutions.CountSolutions);
            Assert.IsTrue(expectedSolutionFirst == solutions.X1 || expectedSolutionFirst == solutions.X2);
            Assert.IsTrue(expectedSolutionSecond == solutions.X1 || expectedSolutionSecond == solutions.X2);
        }