Exemplo n.º 1
0
        public ActionResult Index(string txtTotalAmount)
        {
            try
            {
                ViewBag.OriginalAmt   = txtTotalAmount;
                ViewBag.CountedChange = ThunderChange.MakeChange(txtTotalAmount);
            }
            catch (FormatException ex)
            {
                ViewBag.ErrorMsg = "* Please enter a valid dollar amount in the box below.";
            }

            return(View());
        }
        public void GetChange()
        {
            var change = ThunderChange.MakeChange(".99");

            Assert.IsTrue(change.Keys.Count > 0);
            Assert.AreEqual(change["half-dollar"], 1);
            Assert.AreEqual(change["quarter"], 1);
            Assert.AreEqual(change["dime"], 2);
            Assert.AreEqual(change["penny"], 4);

            change = ThunderChange.MakeChange("1.56");
            Assert.AreEqual(change["silver-dollar"], 1);
            Assert.AreEqual(change["half-dollar"], 1);
            Assert.AreEqual(change["nickel"], 1);
            Assert.AreEqual(change["penny"], 1);

            change = ThunderChange.MakeChange("12.85");
            Assert.IsTrue(change.Keys.Count > 0);
            Assert.AreEqual(change["silver-dollar"], 12);
            Assert.AreEqual(change["half-dollar"], 1);
            Assert.AreEqual(change["quarter"], 1);
            Assert.AreEqual(change["dime"], 1);
        }