Exemplo n.º 1
0
        public void ExecuteTransaction_AddsTransactionToListIfSuccessful_True()
        {
            BarcodeSystem barcodeSystem = Substitute.For <BarcodeSystem>(log);
            User          user          = Substitute.For <User>(userArgs);
            Product       product       = Substitute.For <Product>(productArgs);

            user.Balance = 100m;

            BuyTransaction successfulTransaction = barcodeSystem.BuyProduct(user, product);

            Assert.That(barcodeSystem.Transactions.Contains(successfulTransaction), Is.True);
        }
Exemplo n.º 2
0
        public void BuyProduct_PurchaseWithEnoughCredit_Succeeds()
        {
            BarcodeSystem barcodeSystem = Substitute.For <BarcodeSystem>(log);
            User          user          = Substitute.For <User>(userArgs);
            Product       product       = Substitute.For <Product>(productArgs);

            user.Balance = 100m;

            BuyTransaction buyTransaction = barcodeSystem.BuyProduct(user, product);

            Assert.That(buyTransaction.Succeeded, Is.True);
        }
Exemplo n.º 3
0
        public void UndoTransaction_UndoTransaction_Success()
        {
            const decimal productPrice  = 10;
            BarcodeSystem barcodeSystem = Substitute.For <BarcodeSystem>(log);
            User          user          = Substitute.For <User>(userArgs);
            Product       product       = Substitute.For <Product>("Milk", productPrice);

            user.Balance = productPrice;

            BuyTransaction transaction = barcodeSystem.BuyProduct(user, product);

            barcodeSystem.UndoTransaction(transaction);

            Assert.That(transaction.Undone, Is.True);
            Assert.That(user.Balance, Is.EqualTo(productPrice));
        }