コード例 #1
0
        public void CheckDatMoney_ReturnNumberOfNickelsRequired_Int()
        {
            //Arrange
            CashMoney testCash = new CashMoney(78);
            int       expected = 15;
            //Act
            int actual = testCash.GetNickels();

            //Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
 public static void UpdateMoney(Mock <ICashMoneyRepositoryExtended> MockCashMoneyRepository, IList <CashMoney> money)
 {
     MockCashMoneyRepository.Setup(mock => mock.UpdateMoney(It.IsAny <double>(), It.IsAny <int>())).Callback(
         (double value, int quantity) =>
     {
         CashMoney cashMoney = money.Where(x => x.MoneyValue == value).FirstOrDefault();
         money.Remove(cashMoney);
         cashMoney.Quantity += quantity;
         money.Add(cashMoney);
     });
 }
コード例 #3
0
 public static void GiveChange(Mock <ICashMoneyRepositoryExtended> MockCashMoneyRepository, IList <CashMoney> money)
 {
     MockCashMoneyRepository.Setup(mock => mock.GiveChange(It.IsAny <double>())).Callback(
         (double change) =>
     {
         IList <CashMoney> changedMoney = CashMoneyRepository.CalculateMinimum(money, change);
         foreach (CashMoney coinFromChange in changedMoney)
         {
             CashMoney cash = money.Where(x => x.MoneyValue == coinFromChange.MoneyValue).FirstOrDefault();
             money.Remove(cash);
             cash.Quantity -= coinFromChange.Quantity;
             money.Add(cash);
         }
     });
 }
コード例 #4
0
        public void CheckDatMoney_ReturnMinimumNumberOfCoins_Dictionary()
        {
            //Arrange
            CashMoney testCash = new CashMoney(92);
            Dictionary <string, int> expected = new Dictionary <string, int> ()
            {
                { "Quarters", 3 },
                { "Dimes", 1 },
                { "Nickels", 1 },
                { "Pennies", 2 }
            };
            //Act
            Dictionary <string, int> actual = testCash.CheckDatMoney();

            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }
コード例 #5
0
        public static void CheckOut()
        {
            string format = "{0, 59}{1, 12}";

            CartView.DrawCart();

            Console.WriteLine(format, "Sub Total: ", $"{Cart.GetSubTotal():C2}");
            Console.WriteLine(format, "Sales Tax: ", $"{Cart.GetSalesTax():C2}");
            Console.WriteLine(format, "Grand Total: ", $"{Cart.GetGrandTotal():C2}");

            PaymentType = GetPaymentType();
            if (PaymentType == 1)
            {
                CashMoney.MakePayment();
            }
            else if (PaymentType == 2)
            {
                CheckMoney.MakePayment();
            }
            else if (PaymentType == 3)
            {
                CreditMoney.MakePayment();
            }
        }
コード例 #6
0
        public ActionResult MakeItRain()
        {
            CashMoney newCash = new CashMoney(int.Parse(Request.Form["cash"]));

            return(View(newCash.CheckDatMoney()));
        }