Ejemplo n.º 1
0
        public void CalculateTipTest()
        {
            var calculator = new TipCalculator();
            var request = new TipCalculationRequest {MealCost = 100, TipPercent = .2M};
            var result = calculator.CalculateTip(request);

            Assert.AreEqual(result.TipAmount, 20M);
            Assert.AreEqual(result.TotalCost, 120M);
        }
Ejemplo n.º 2
0
        public ActionResult TipCalculator(TipCalculatorRequest request)
        {
            if (ModelState.IsValid)
            {

                var calc = new TipCalculator();

                var tipData = new MVCappLabs.Models.Level1.TipCalculationRequest();
                tipData.MealCost = request.MealCost.Value;
                tipData.TipPercent = request.TipPercent.Value / 100;

                var response = calc.CalculateTip(tipData);

                return View("TipCalculatorResponse", response);

            }
            return View("TipCalculator");
        }