Esempio n. 1
0
        public int CalculateAgeFromDOB(string input)
        {
            DateTime DOB = new DateTime();

            try
            {
                DOB = Convert.ToDateTime(input);
            }
            catch (FormatException)
            {
                Console.WriteLine("{0} is not a valid date", input);
                ApplicantDetails foo = new ApplicantDetails();
                foo.ItsAllBroken();
            }

            DateTime today = DateTime.Today;

            Age = today.Year - DOB.Year;

            if (DOB > today.AddYears(-Age))
            {
                Age--;
            }

            return(Age);
        }
Esempio n. 2
0
        public void RegionalHealthIndexEngland_AppliesNoDiscountOrLoad()
        {
            CountryOfResidence bar = new CountryOfResidence();
            ApplicantDetails   foo = new ApplicantDetails();

            foo.Country = CountryOfResidence.Country.England;
            Assert.AreEqual(bar.ReturnRHIDifference(foo.Country), 0);
        }
Esempio n. 3
0
        public void BaseRateFor70YearOldFemale_ShouldBe485()
        {
            BasePrice        b   = new BasePrice();
            ApplicantDetails foo = new ApplicantDetails {
                Age = 70, isMale = false
            };

            Assert.AreEqual(b.ReturnBasePrice(foo), 485);
        }
Esempio n. 4
0
        public void BaseRateFor10YearOldBoy_ShouldBe150()
        {
            BasePrice        b   = new BasePrice();
            ApplicantDetails foo = new ApplicantDetails {
                Age = 10, isMale = true
            };

            Assert.AreEqual(b.ReturnBasePrice(foo), 150);
        }
Esempio n. 5
0
        public void CorrectFinalPremiumCalculated()
        {
            ApplicantDetails app = new ApplicantDetails();

            app.Age             = 36;
            app.isMale          = true;
            app.Country         = CountryOfResidence.Country.England;
            app.HasChildren     = true;
            app.IsSmoker        = false;
            app.WeeklyExcercise = 2;

            CalculateQuote CQ = new CalculateQuote();

            Assert.AreEqual(CQ.CalculateFinalQuote(app), 375);
        }
Esempio n. 6
0
        public decimal CalculateFinalQuote(ApplicantDetails quote)
        {
            decimal BasePremium = new BasePrice().ReturnBasePrice(quote);

            decimal AfterRHI = BasePremium + new CountryOfResidence().ReturnRHIDifference(quote.Country);

            ChildLoading child = new ChildLoading();
            decimal      PremiumAfterChildLoad = child.ApplyChildLoading(AfterRHI, quote.HasChildren);

            SmokerLoading smoke = new SmokerLoading();
            decimal       PremiumAfterSmoking = smoke.ApplySmokerLoading(PremiumAfterChildLoad, quote.IsSmoker);

            HealthyLifeStyleBonus HLB = new HealthyLifeStyleBonus();
            decimal PremiumAfterLifeStyleAdjustment = HLB.ApplyLifeStyleBonus(PremiumAfterSmoking, quote.WeeklyExcercise);

            return(PremiumAfterLifeStyleAdjustment);
        }
Esempio n. 7
0
        public Country SelectCountry()
        {
            Console.WriteLine("Please select your contry of residence from the list below");
            Console.WriteLine("1. England");
            Console.WriteLine("2. Wales");
            Console.WriteLine("3. Scotland");
            Console.WriteLine("4. Ireland");
            Console.WriteLine("5. Northern Ireland");
            Console.WriteLine("6. Any Other Country");

            int selected = Convert.ToInt32(Console.ReadLine());

            if (selected == 1)
            {
                return(Country.England);
            }
            else if (selected == 2)
            {
                return(Country.Wales);
            }
            else if (selected == 3)
            {
                return(Country.Scotland);
            }
            else if (selected == 4)
            {
                return(Country.Ireland);
            }
            else if (selected == 5)
            {
                return(Country.NorthernIreland);
            }
            else if (selected == 6)
            {
                return(Country.Other);
            }
            else
            {
                ApplicantDetails foo = new ApplicantDetails();
                foo.ItsAllBroken();
                return(Country.Other);
            }
        }
Esempio n. 8
0
        public decimal ReturnBasePrice(ApplicantDetails App)
        {
            List <BasePrice> list = LoadBasePrice();

            foreach (BasePrice Price in list)
            {
                if (App.Age >= Price.LowerAge && App.Age <= Price.MaxAge)
                {
                    if (App.isMale == Price.isMale)
                    {
                        return(Price.Base);
                    }
                }
            }

            CalculateQuote foo = new CalculateQuote();

            foo.CalculationError("Base Premium");
            return(0);
        }
Esempio n. 9
0
        public ApplicantDetails CollectQuoteData()
        {
            ApplicantDetails quote = new ApplicantDetails();

            Console.WriteLine("Please enter your date of birth in dd/mm/yyyy format. For example today is {0}/{1}/{2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year);
            quote.Age = quote.CalculateAgeFromDateOfBirth(Console.ReadLine());

            Console.WriteLine("Please Select Your Gender {0} 1. Male {0} 2. Female", Environment.NewLine);
            try
            {
                quote.isMale = quote.SetGender(Console.ReadLine());
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Please try again");
                quote.isMale = quote.SetGender(Console.ReadLine());
            }


            CountryOfResidence country = new CountryOfResidence();

            quote.Country = country.SelectCountry();

            Console.WriteLine("Please Enter your post code");
            quote.PostCode = Console.ReadLine();

            Console.WriteLine("Are you a smoker?, please enter Y for Yes, N for No");
            quote.IsSmoker = quote.SetSmoker(Console.ReadLine());

            Console.WriteLine("Please tell us how many hours of excercise you do in a week");
            quote.WeeklyExcercise = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Do you have any children?, please enter Y for Yes, N for No");
            quote.HasChildren = quote.SetChildren(Console.ReadLine());

            return(quote);
        }
Esempio n. 10
0
        public void WhenNSelected_HasChildrenIsFalse()
        {
            ApplicantDetails foo = new ApplicantDetails();

            Assert.AreEqual(foo.SetChildren("N"), false);
        }
Esempio n. 11
0
        public void WhenYSelected_HasChildrenIsTrue()
        {
            ApplicantDetails foo = new ApplicantDetails();

            Assert.AreEqual(foo.SetChildren("Y"), true);
        }
Esempio n. 12
0
        public void WhenNEnteredForSmoker_IsSmokerReturnsFalse()
        {
            ApplicantDetails foo = new ApplicantDetails();

            Assert.AreEqual(foo.SetSmoker("N"), false);
        }
Esempio n. 13
0
        public void WhenYEnteredForSmoker_IsSmokerReturnsTrue()
        {
            ApplicantDetails foo = new ApplicantDetails();

            Assert.AreEqual(foo.SetSmoker("Y"), true);
        }
Esempio n. 14
0
        public void WhenFemaleIsSelected_IsMaleReturnsFalse()
        {
            ApplicantDetails foo = new ApplicantDetails();

            Assert.AreEqual(foo.SetGender("2"), false);
        }
Esempio n. 15
0
        public void WhenMaleSelected_IsMaleReturnsTrue()
        {
            ApplicantDetails foo = new ApplicantDetails();

            Assert.AreEqual(foo.SetGender("1"), true);
        }