public double Calculate(Employee employee, double current)
        {
            var cost = 1000d;

            cost = _nameStartsWithADiscount.CalculateDiscount(employee.Name, cost);
            return(current + cost);
        }
 public double Calculate(Employee employee, double current)
 {
     foreach (var dependent in employee.Dependents)
     {
         var cost = 500d;
         cost     = _nameStartsWithADiscount.CalculateDiscount(dependent.Name, cost);
         current += cost;
     }
     return(current);
 }
        public void CalculateReturnsOneThousend()
        {
            INameStartsWithADiscount discountRule = NSubstitute.Substitute.For <INameStartsWithADiscount>();

            discountRule.CalculateDiscount(null, 1000).Returns(1000);
            var      rule     = new CostPerYearCalculateRule(discountRule);
            Employee employee = new Employee();
            var      expected = 1000;

            Assert.AreEqual(expected, rule.Calculate(employee, 0));
        }
        public void CalculateReturnsOneThousend()
        {
            INameStartsWithADiscount discountRule = NSubstitute.Substitute.For <INameStartsWithADiscount>();

            discountRule.CalculateDiscount(null, 500).Returns(500);
            var      rule     = new EechDependentCalculateRule(discountRule);
            Employee employee = new Employee();

            employee.Dependents.Add(new Dependent());
            employee.Dependents.Add(new Dependent());
            var expected = 1000;

            Assert.AreEqual(expected, rule.Calculate(employee, 0));
        }