public void Deposit_WithValidAmount_UpdatesLastTransactionBalance() { //Arrange var user = new User { Username = "******", FirstName = "Demo", LastName = "User", Password = "******" }; new AuthService().Register(user); decimal depositAmount1 = 5; decimal depositAmount2 = 2; decimal expected = depositAmount1 + depositAmount2; UserTransactionService transactionService = new UserTransactionService(); //act transactionService.Deposit(user.Id, depositAmount1); transactionService.Deposit(user.Id, depositAmount2); //Assert var balance = transactionService.GetCurrentBalanceForUser(user.Id); Assert.AreEqual(expected, balance, "Wrong balance value"); }
public override void Run(bool clearScreen = true) { if (clearScreen) { Console.Clear(); } Console.WriteLine($"Deposit for {User.Username}\n"); Console.Write("Enter amount to deposit: "); var amount = UserInputHelper.GetDecimal(); Console.Write($"Depost {amount:C}. Are you sure? (y/n) : "); var confirm = Console.ReadLine(); if (confirm == "y" || confirm == "Y") { var res = UserTransactionService.Deposit(User.Id, amount); if (res.Success) { Console.WriteLine("Deposit Success!"); } else { Console.WriteLine($"Deposit Failed. {res.Errors}"); } } else { Console.WriteLine("Deposit Cancelled!"); } ShowDoneOptions(); }
public void Deposit_WithValidAmount_AddedToTransactionList() { //Arrange var user = new User { Username = "******", FirstName = "Demo", LastName = "User", Password = "******" }; new AuthService().Register(user); UserTransactionService transactionService = new UserTransactionService(); //act transactionService.Deposit(user.Id, 5); //Assert var allTransactions = transactionService.GetTransactionsForUser(user.Id); Assert.IsTrue(allTransactions.Count() > 0, "Wrong transaction list count"); }
public void Transaction_LastTransactionNotNull() { //Arrange var user = new User { Username = "******", FirstName = "Demo", LastName = "User", Password = "******" }; new AuthService().Register(user); UserTransactionService transactionService = new UserTransactionService(); //act transactionService.Deposit(user.Id, 5); //Assert var lastTransaction = transactionService.GetLastTransactionForUser(user.Id); Assert.IsNotNull(lastTransaction, "Wrong last transaction is null"); }