Exemplo n.º 1
0
        public void CreateMoneyTransfer_AddsTransferWithCorrectAmount_ToSenderPendingTransfers()
        {
            // ACT
            IMoneyTransfer transfer = _accountService.CreateMoneyTransfer(_sender, _recipient, _defaultTransferAmount);

            // ASSERT
            Assert.AreEqual(_defaultTransferAmount, transfer.Amount);
        }
Exemplo n.º 2
0
        public void ExecuteMoneyTransfer_AddsTransfer_ToRecipientCompletedTransfers()
        {
            // ARRANGE
            IMoneyTransfer transfer = _accountService.CreateMoneyTransfer(_sender, _recipient, _defaultTransferAmount);

            // ACT
            _accountService.ExecuteMoneyTransfer(transfer);
            var transferInRecipientCompletedTransfers = _recipient.CompletedTransfers.Contains(transfer);

            // ASSERT
            Assert.IsTrue(transferInRecipientCompletedTransfers);
        }
Exemplo n.º 3
0
        public void ExecuteMoneyTransfer_RemovesTransfer_FromSenderPendingTransfers()
        {
            // ARRANGE
            IMoneyTransfer transfer = _accountService.CreateMoneyTransfer(_sender, _recipient, _defaultTransferAmount);

            // ACT
            _accountService.ExecuteMoneyTransfer(transfer);
            var transferInSenderPendingTransfers = _sender.PendingTransfers.Contains(transfer);

            // ASSERT
            Assert.IsFalse(transferInSenderPendingTransfers);
        }
Exemplo n.º 4
0
        public void ExecuteMoneyTransfer_AddsCorrectAmount_ToRecipientBalance()
        {
            // ARRANGE
            var            recipientInitialBalance = _recipient.Balance;
            IMoneyTransfer transfer = _accountService.CreateMoneyTransfer(_sender, _recipient, _defaultTransferAmount);

            // ACT
            _accountService.ExecuteMoneyTransfer(transfer);

            // ASSERT
            Assert.AreEqual(recipientInitialBalance + _defaultTransferAmount, _recipient.Balance);
        }
Exemplo n.º 5
0
        public bool ExecuteMoneyTransfer(IMoneyTransfer transfer)
        {
            if (transfer.Completed)
            {
                return(false);
            }

            transfer.Recipient.Balance += transfer.Amount;
            transfer.Sender.PendingTransfers.Remove(transfer);
            transfer.Sender.CompletedTransfers.Add(transfer);
            transfer.Recipient.CompletedTransfers.Add(transfer);
            transfer.SetCompleted();

            return(true);
        }
Exemplo n.º 6
0
        public void CreateMoneyTransfer_CreatesMoneyTransfer_WithCorrectAmount()
        {
            // ARRANGE
            var amount        = 100.0M;
            var senderBalance = amount;
            var senderMock    = new Mock <IUser>();

            senderMock.Setup(x => x.Balance).Returns(senderBalance);
            senderMock.Setup(x => x.PendingTransfers).Returns(new List <IMoneyTransfer>());
            var recipientMock = new Mock <IUser>();

            // ACT
            IMoneyTransfer transfer = _accountService.CreateMoneyTransfer(senderMock.Object, recipientMock.Object, amount);

            // ASSERT
            Assert.AreEqual(amount, transfer.Amount);
        }
Exemplo n.º 7
0
        public void ExecuteMoneyTransfer_ReturnsTrue_WhenTransferSucceeded()
        {
            // ARRANGE
            var amount        = 100.0M;
            var senderBalance = amount;
            var senderMock    = new Mock <IUser>();

            senderMock.Setup(x => x.Balance).Returns(senderBalance);
            senderMock.Setup(x => x.PendingTransfers).Returns(new List <IMoneyTransfer>());
            senderMock.Setup(x => x.CompletedTransfers).Returns(new List <IMoneyTransfer>());
            var recipientMock = new Mock <IUser>();

            recipientMock.Setup(x => x.CompletedTransfers).Returns(new List <IMoneyTransfer>());
            IMoneyTransfer transfer = _accountService.CreateMoneyTransfer(senderMock.Object, recipientMock.Object, amount);

            // ACT
            var result = _accountService.ExecuteMoneyTransfer(transfer);

            // ASSERT
            Assert.IsTrue(result);
        }
Exemplo n.º 8
0
 public MoneyTransfer(string to, decimal amount)
 {
     To        = to;
     Amount    = amount;
     payMaster = Activator.CreateInstance <T>();
 }
Exemplo n.º 9
0
 public void ResloveMethods()
 {
     balllanceaccount = container.Resolve <IBalllanceAccount>();
     moneyspend       = container.Resolve <IMoneySpend>();
     moneytransfer    = container.Resolve <IMoneyTransfer>();
 }