예제 #1
0
        public void AddTest(int number1, int number2, int expected)
        {
            CalculatorBL calculator = new CalculatorBL();
            var          result     = calculator.Add(number1, number2);

            Assert.Equal(expected, result);
        }
예제 #2
0
        public SqrtResult Sqrt([FromBody] SqrtRequest sqrtRequest)
        {
            var    headers     = this.Request.Headers.ToList();
            string tracking_ID = headers[headers.Count - 1].Value.First().ToString();

            return(CalculatorBL.Sqrt(sqrtRequest, tracking_ID));
        }
예제 #3
0
        public DivtResult Div([FromBody] DivtRequest divtRequest)
        {
            var    headers     = this.Request.Headers.ToList();
            string tracking_ID = headers[headers.Count - 1].Value.First().ToString();

            return(CalculatorBL.Div(divtRequest, tracking_ID));
        }
예제 #4
0
        public AddResult Add([FromBody] AddRequest addRequest)
        {
            var    headers     = this.Request.Headers.ToList();
            string tracking_ID = headers[headers.Count - 1].Value.First().ToString();

            return(CalculatorBL.Add(addRequest, tracking_ID));
        }
예제 #5
0
        public void AddTest()
        {
            var number1  = 10;
            var number2  = 20;
            var expected = 30;

            CalculatorBL calculator = new CalculatorBL();
            var          result     = calculator.Add(number1, number2);

            Assert.Equal(expected, result);
        }
예제 #6
0
        public IActionResult GetPremiumValue(CalculatorModel model)
        {
            List <ConfigurationData> lstData = new List <ConfigurationData>();

            try
            {
                using (ICalculatorBL CalculatorBL = new CalculatorBL())
                {
                    //Load configuration data to do calculation
                    lstData = CalculatorBL.LoadConfigurationData();

                    //Evaluate parameters (BirthDate, state and age) with data
                    var vResult = lstData.FirstOrDefault(t => {
                        if (model.State == Enums.StateName.cStateNY || model.State == Enums.StateName.cStateAL)
                        {
                            if (t.State == model.State && t.BirthMonth == model.BirthDate.Month && (t.StartAge <= model.Age && t.EndAge >= model.Age))
                            {
                                return(true);
                            }
                            else if (t.State == model.State && t.BirthMonth == Enums.ValidationType.cAllMonths && t.StartAge <= model.Age && t.EndAge >= model.Age)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (model.State == Enums.StateName.cStateAK)
                        {
                            if (t.State == model.State && t.BirthMonth == model.BirthDate.Month && (t.StartAge <= model.Age && t.EndAge >= model.Age))
                            {
                                return(true);
                            }
                            else if (t.State == model.State && t.BirthMonth == model.BirthDate.Month && t.StartAge <= model.Age)
                            {
                                return(true);
                            }
                            else if (t.State == model.State && t.BirthMonth == Enums.ValidationType.cAllMonths && t.StartAge <= model.Age && t.EndAge >= model.Age)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (t.State == Enums.ValidationType.cAllStates && t.BirthMonth == Enums.ValidationType.cAllMonths && t.StartAge <= model.Age && t.EndAge >= model.Age)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    });


                    return(Ok(vResult));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
예제 #7
0
        public void FailingAddTest()
        {
            CalculatorBL calculator = new CalculatorBL();

            Assert.Equal(5, calculator.Add(2, 2));
        }
예제 #8
0
 public List <Operations> Query([FromBody] string id)
 {
     return(CalculatorBL.Query(id));
 }