public void TestWithdrawFromAccount_InvalidAccount() { MockLogging mockLogging = new MockLogging(); MockBank mockBank = new MockBank("123123", 600); BankAccount b = new BankAccount("123123-Invalid", mockLogging, mockBank); Assert.That(() => b.Withdraw(500), Throws.ArgumentException); }
public void TestWithdrawFromAccount_NotEnoughMoney() { MockLogging mockLogging = new MockLogging(); MockBank mockBank = new MockBank("123123", 400); BankAccount b = new BankAccount("123123", mockLogging, mockBank); Assert.That(()=>b.Withdraw(500), Throws.ArgumentException); }
public void TestWithdrawFromAccount_InvalidAccount() { MockLogging mockLogging = new MockLogging(); MockBank mockBank = new MockBank("123123", 600); BankAccount b = new BankAccount("123123-Invalid", mockLogging, mockBank); Assert.That(() => b.Withdraw(500), Throws.ArgumentException); }
public void TestWithdrawFromAccount_NotEnoughMoney() { MockLogging mockLogging = new MockLogging(); MockBank mockBank = new MockBank("123123", 400); BankAccount b = new BankAccount("123123", mockLogging, mockBank); Assert.That(() => b.Withdraw(500), Throws.ArgumentException); }
public void TestWithdrawFromAccount_EnoughMoney() { MockLogging mockLogging = new MockLogging(); MockBank mockBank = new MockBank("123123", 600); BankAccount b = new BankAccount("123123", mockLogging, mockBank); b.Withdraw(500); Assert.That(mockBank.RequiredSumma, Is.EqualTo(500)); }
public void TestWithdrawFromAccount_EnoughMoney() { MockLogging mockLogging = new MockLogging(); MockBank mockBank = new MockBank("123123", 600); BankAccount b = new BankAccount("123123", mockLogging, mockBank); b.Withdraw(500); Assert.That(mockBank.RequiredSumma, Is.EqualTo(500)); }
public void WithdrawTest() { ATM atm = new ATM(); MockBank mockBank = new MockBank(); atm.BankInstance = mockBank; atm.Withdraw(0); Assert.AreEqual(0, mockBank.AmountWithdrawn); atm.Withdraw(30); Assert.AreEqual(30, mockBank.AmountWithdrawn); }
public void DepositTest() { ATM atm = new ATM(); MockBank mockBank = new MockBank(); atm.BankInstance = mockBank; atm.Deposit(0); Assert.AreEqual(0, mockBank.AmountDeposited); atm.Deposit(10); Assert.AreEqual(10, mockBank.AmountDeposited); }
public void WithdrawTest() { Teller teller = new Teller(); MockBank mockBank = new MockBank(); teller.BankInstance = mockBank; teller.Withdraw(0); Assert.AreEqual(0, mockBank.AmountWithdrawn); teller.Withdraw(20); Assert.AreEqual(20, mockBank.AmountWithdrawn); }
public void DepositTest() { Teller teller = new Teller(); MockBank mockBank = new MockBank(); teller.BankInstance = mockBank; teller.Deposit(0); Assert.AreEqual(0, mockBank.AmountDeposited); teller.Deposit(50); Assert.AreEqual(50, mockBank.AmountDeposited); }
public ActionResult <Transaction> ProcessTransaction(TransactionRepresenter transactionRepresenter) { var transaction = new Transaction(); transaction.MerchantId = transactionRepresenter.MerchantId; transaction.BankId = transactionRepresenter.BankId; transaction.Currency = transactionRepresenter.Currency; transaction.CardType = transactionRepresenter.CardType; transaction.CardNumber = transactionRepresenter.CardNumber; transaction.NameOnCard = transactionRepresenter.NameOnCard; transaction.ExpiryMonth = transactionRepresenter.ExpiryMonth; transaction.ExpiryYear = transactionRepresenter.ExpiryYear; transaction.CVV = transactionRepresenter.CVV; transaction.Amount = transactionRepresenter.Amount; var merchant = _context.Merchants.Find(transaction.MerchantId); var bank = _context.Banks.Find(transaction.BankId); if (merchant is null) { return(NotFound("Merchant not found!")); } if (bank is null) { return(NotFound("Bank not found!")); } var mockBank = new MockBank(); mockBank.CardType = transaction.CardType; mockBank.CardNumber = transaction.CardNumber; mockBank.NameOnCard = transaction.NameOnCard; mockBank.ExpiryMonth = transaction.ExpiryMonth; mockBank.ExpiryYear = transaction.ExpiryYear; mockBank.CVV = transaction.CVV; mockBank.Amount = transaction.Amount; var bankresponse = new BankResponse(); bankresponse = MockBankController.ProcessTransaction(mockBank); transaction.BankResponseId = bankresponse.Id; transaction.BankResponse = bankresponse.Response; transaction.Status = bankresponse.Status; _context.Transactions.Add(transaction); _context.SaveChanges(); return(transaction); }
public static BankResponse ProcessTransaction(MockBank mockbank) { var response = new BankResponse(); int i = 0; response.Response = "Successful"; response.Status = "Successful"; if (!(mockbank.CVV.ToString().Length == 3)) { response.Response = "Security Breach"; response.Status = "Failed"; } if (mockbank.Amount > 100000) { response.Response = "Not enough fund"; response.Status = "Failed"; } if (!(mockbank.CardNumber.Length == 12) && (int.TryParse(mockbank.CardNumber, out i) == true)) { response.Response = "Invalid Card Number"; response.Status = "Failed"; } if (mockbank.ExpiryYear < DateTime.Now.Year) { response.Response = "Card has expired"; response.Status = "Failed"; } if ((mockbank.ExpiryYear == DateTime.Now.Year) && (Int32.Parse(mockbank.ExpiryMonth) < DateTime.Now.Month)) { response.Response = "Card has expired"; response.Status = "Failed"; } response.Id = Guid.NewGuid(); return(response); }