public void CalculateReturnChangeTest() { var calculator = new ChangeReturnCalculator(); var request = new ChangeReturnRequest() { UserCash = 2.00M, ItemCost = 1.32M }; var result = calculator.CalculateChange(request); Assert.AreEqual(result.Quarters, 2); Assert.AreEqual(result.Dimes, 1); Assert.AreEqual(result.Nickels, 1); Assert.AreEqual(result.Pennies, 3); }
public ActionResult ChangeReturnInput(ChangeReturnModel request) { if (ModelState.IsValid) { var changeFind = new ChangeReturnCalculator(); var changeData = new ChangeReturnRequest(); changeData.UserCash = request.UserCash; changeData.ItemCost = (decimal)(request.ItemCost); var result = changeFind.CalculateChange(changeData); return(View("ChangeReturnOutput", result)); } else { return(View(request)); } }