Exemplo n.º 1
0
        public void GetSquareSeries_NegativeNumber_EmptyArr()
        {
            //arrange
            int        number     = -10;
            MathFinder mathFinder = new MathFinder();

            //act
            var actual = mathFinder.GetSquareSeries(number);

            //assert
            Assert.Empty(actual);
        }
Exemplo n.º 2
0
        public void GetSquareSeries_Number0_NoItems()
        {
            //arrange
            int        number     = 0;
            MathFinder mathFinder = new MathFinder();

            //act
            var actual = mathFinder.GetSquareSeries(number);

            //assert
            Assert.Empty(actual);
        }
Exemplo n.º 3
0
        public void GetFibonacciSeries_EndLessThanStart_NoItems()
        {
            //arrange
            int        start      = 10;
            int        end        = 5;
            MathFinder mathFinder = new MathFinder();

            //act
            var actual = mathFinder.GetFibonacciSeries(start, end);

            //assert
            Assert.Empty(actual);
        }
Exemplo n.º 4
0
        public void GetFibonacciSeries_StartNegativeEndNegative_NoItems()
        {
            //arrange
            int        start      = -10;
            int        end        = -10;
            MathFinder mathFinder = new MathFinder();

            //act
            var actual = mathFinder.GetFibonacciSeries(start, end);

            //assert
            Assert.Empty(actual);
        }
Exemplo n.º 5
0
        public void GetSquareSeries_Number8_3Items()
        {
            //arrange
            int        number     = 8;
            MathFinder mathFinder = new MathFinder();

            int expected = 3;

            //act
            var actual = mathFinder.GetSquareSeries(number);

            //assert
            Assert.Equal(expected, actual.Length);
        }
Exemplo n.º 6
0
        public void GetFibonacciSeries_Start0End3_3Items()
        {
            //arrange
            int        start      = 0;
            int        end        = 3;
            MathFinder mathFinder = new MathFinder();

            int expected = 3;

            //act
            var actual = mathFinder.GetFibonacciSeries(start, end);

            //assert
            Assert.Equal(expected, actual.Length);
        }
        public static void ShowConsoleMenu(string[] inputParams)
        {
            bool isNewTry = false;
            int  result;

            do
            {
                if (isNewTry)
                {
                    result = AskMenuItem("Choose program mode",
                                         new string[] { InputData.Mode.Square.ToString(),
                                                        InputData.Mode.Fibonacci.ToString() });

                    inputParams = AskInputParams((InputData.Mode)result);
                    isNewTry    = false;
                }

                if (!Validator.IsValidArgs(inputParams))
                {
                    Console.WriteLine("Your data is not valid");
                    if (!AskBoolValue("Do you want to retype them?",
                                      new string[] { "YES", "Y" }))
                    {
                        break;
                    }

                    result = AskMenuItem("Choose program mode",
                                         new string[] { InputData.Mode.Square.ToString(),
                                                        InputData.Mode.Fibonacci.ToString() });

                    inputParams = AskInputParams((InputData.Mode)result);

                    continue;
                }

                InputData inputData = Parser.ParseArgs(inputParams);

                switch (inputData.ProgramMode)
                {
                case InputData.Mode.Square:
                    ISquareSeriesFinder square =
                        new MathFinder();
                    int[] squareSeries = square.GetSquareSeries(
                        inputData.SquaryValue);
                    PrintArray("Square series: ", squareSeries);
                    break;

                case InputData.Mode.Fibonacci:
                    IFibonacciSeriesMaker fibonacci =
                        new MathFinder();
                    int[] fibonacciSeries = fibonacci.GetFibonacciSeries(
                        inputData.StartFibonacciRange,
                        inputData.EndFibonacciRange);
                    PrintArray("Fibonacci series: ", fibonacciSeries);
                    break;
                }


                if (AskBoolValue("Do you want to continue?",
                                 new string[] { "YES", "Y" }))
                {
                    isNewTry = true;
                }
                else
                {
                    break;
                }
            } while (true);
        }