public void GetFibonacciNumbers(CalculatorModel model)
 {
     List<int> listOfNumbers = new List<int>();
     for (int i = 1; i <= Convert.ToInt32(model.number); i++)
     {
         model.fibonacci.Add(GetFibonacci(i));
     }
 }
 public void Calculator_AddNegativeValue_ReturnError()
 {
     // Arrange
     CalculatorModel calculateModel = new CalculatorModel();
     calculateModel.number = -10;
     // Act
     var validationResult = Validator.TryValidateObject(calculateModel, new ValidationContext(calculateModel, null, null), null, true);
     // Assert
     Assert.IsFalse(validationResult);
 }
        private void GetOddAndEvenNumbers(CalculatorModel model)
        {
            for (int i = 1; i <= Convert.ToInt32(model.number); i++)
            {
                if (i % 2 == 0)
                {
                    model.evenNumbers.Add(i);
                }
                else
                {
                    model.oddNumbers.Add(i);
                }

            }
        }
        public void Calculator_AddNegativeValue_GetView()
        {
            // Arrange
            CalculatorModel calculateModel = new CalculatorModel();
            calculateModel.number = 10;
            ActionResult result = null;
            // Act
            var validationResult = Validator.TryValidateObject(calculateModel, new ValidationContext(calculateModel, null, null), null, true);
            Assert.IsTrue(validationResult);

            CalculatorController calculateCnt = new CalculatorController();
            result = calculateCnt.Calculate(calculateModel);
            ViewResult viewResult = (ViewResult)result;
            calculateModel = (CalculatorModel)viewResult.Model;

            Assert.IsNotNull(calculateModel.evenNumbers);
        }
        public ActionResult Calculate(CalculatorModel model)
        {
            if (!ModelState.IsValid)
            {
                return View("Index");
            }
            //validate bayad beshe
            model.oddNumbers = new List<int>();
            model.evenNumbers = new List<int>();
            model.special = new List<string>();
            model.fibonacci = new List<int>();

            GetOddAndEvenNumbers(model);
            GetSpecialNumbers(model);
            GetFibonacciNumbers(model);

            return View(model);
        }
 private void GetSpecialNumbers(CalculatorModel model)
 {
     for (int i = 1; i <= Convert.ToInt32(model.number); i++)
     {
         if ((i % 3 == 0) && (i % 5 == 0))
         {
             model.special.Add("Z");
             continue;
         }
         else if ((i % 3 == 0))
         {
             model.special.Add("C");
             continue;
         }
         else if (i % 5 == 0)
         {
             model.special.Add("E");
             continue;
         }
         model.special.Add(i.ToString());
     }
 }