public void Can_Calculate_TotalCostOfBenefits_Some_Dependents_Names_Start_With_Discount_Letter()
        {
            var employee = new Employee();
            employee.Name = "Thomas";
            employee.Dependents = new Collection<Dependent>();

            var dependent1 = new Dependent();
            dependent1.Name = "Allison";
            employee.Dependents.Add(dependent1);

            var dependent2 = new Dependent();
            dependent2.Name = "Alfred";
            employee.Dependents.Add(dependent2);

            var dependent3 = new Dependent();
            dependent3.Name = "Rick";
            employee.Dependents.Add(dependent3);

            var result = _service.TotalCostOfBenefits(employee);

            // full-cost employee, full-cost dependent, 2 discounted dependents
            decimal expectedCost = 1000 + 500 + 450 + 450;

            Assert.AreEqual(result, expectedCost);
        }
        public void Can_Calculate_DependentCostOfBenefits_Name_Starts_With_Discount_Letter()
        {
            var dependent = new Dependent();
            dependent.Name = "Alfred";

            var result = _service.CalculateDependentCostOfBenefits(dependent);

            Assert.AreEqual(result, 450);
        }
        public decimal CalculateDependentCostOfBenefits(Dependent dependent)
        {
            if (!string.IsNullOrEmpty(dependent.Name) && dependent.Name.StartsWith(_discountLetter))
            {
                return _dependentCost * (1 - _discountPercentage);
            }

            return _dependentCost;
        }