Exemple #1
0
        public ActionResult Costs(Benefits benefits)
        {
            List <string> dependents = new List <string>();

            if (string.IsNullOrEmpty(benefits.EmployeeName))
            {
                benefits.Message = "Please enter Employee Name";
                return(View("Benefits", benefits));
            }

            if (string.IsNullOrEmpty(benefits.Dependents) == false)
            {
                string[] separators = { ",", ".", "!", "?", ";", ":", " " };
                dependents = benefits.Dependents.Split(separators, StringSplitOptions.RemoveEmptyEntries).ToList();
            }

            decimal cost     = BenefitCalculator.CalculateCost(benefits.EmployeeName, dependents);
            decimal grossPay = BenefitCalculator.CalculateGrossPay();
            decimal netPay   = grossPay - cost;

            benefits.GrossPayMessage = $"Gross Pay: ${grossPay}";
            benefits.CostMessage     = $"Cost of Benefits: ${ cost}";
            benefits.NetPayMessage   = $"Net Pay:${netPay}";

            return(View("Benefits", benefits));
        }
Exemple #2
0
        public void TestCalculateCostAjayOnly()
        {
            decimal cost = BenefitCalculator.CalculateCost("Ajay", new List <string>()
            {
            });

            Assert.IsTrue(cost == 900);
        }
Exemple #3
0
        public void TestCalculateCostEmplooyeeOnly()
        {
            decimal cost = BenefitCalculator.CalculateCost("Haresh", new List <string>()
            {
            });

            Assert.IsTrue(cost == 1000);
        }
Exemple #4
0
        public void TestCalculateCost()
        {
            decimal cost = BenefitCalculator.CalculateCost("Haresh", new List <string>()
            {
                "Nikita", "Aditya", "Alisha"
            });

            Assert.IsTrue(cost == 2400);
        }