static void Main(string[] args) { BankAccount.BankAccount user1 = new BankAccount.BankAccount("Ivan Ivanovich", "+375 29 1234567", "Kuprevicha 17 123", "Gold"); Console.Write(user1.ShowAcc()); user1.RefillOrDebit(123.123); user1.RefillOrDebit(123.123); user1.RefillOrDebit(-40.123); Console.Write(user1.ShowAcc()); user1.Delete(); Console.Write(user1.ShowAcc()); BankAccount.BankAccount user2 = new BankAccount.BankAccount("Akim Ivanovich", "+375 29 1265567", "Korolia 1 13", "Platinum"); Console.Write(user2.ShowAcc()); user2.RefillOrDebit(12323.123); user2.RefillOrDebit(123.123); user2.RefillOrDebit(-40.123); Console.Write(user2.ShowAcc()); user1.Delete(); Console.Write(user2.ShowAcc()); BankAccount.BankAccount user3 = new BankAccount.BankAccount("Mary Ivanovich", "+375 29 1265567", "Korolia 1 13", "Platinum"); Console.Write(user3.ShowAcc()); user3.RefillOrDebit(12.123); user3.RefillOrDebit(-123.123);//Exception Console.Write(user3.ShowAcc()); Console.ReadKey(); }
public Bill( User.User user, BankAccount.BankAccount account, string shopName, double price, DateTime?date, string?notes, Category category) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (account == null) { throw new ArgumentNullException(nameof(account)); } this.CreatedByUserId = user.Id; this.BankAccountId = account.Id; this.ShopName = shopName; this.Price = price; this.Date = date ?? DateTime.UtcNow; this.Notes = notes ?? string.Empty; this.Category = category; this.CreatedByUser = user; this.BankAccount = account; }
public void BalanceInitialization_WithoutValue_ShouldEqualZero() { int zero = 0; var account = new Sut(); Assert.AreEqual(zero, account.Balance); }
public void BalanceInitialization_WithPositiveValue_ShouldEqualValue() { int value = 10; var account = new Sut(value); Assert.AreEqual(value, account.Balance); }
public void Withdraw_ShouldThrowException_WhenGivenNegativeAmount() { int negativeAmount = -10; var account = new Sut(); Assert.Throws <ArgumentException>(() => account.Withdraw(negativeAmount)); }
public void Deposit_ShouldThrowArgumentException_WhenGivenNegativeAmount() { int negativeAmount = -10; int balance = 20; var account = new Sut(balance); Assert.Throws <ArgumentException>(() => account.Deposit(negativeAmount)); }
public void Withdraw_ShouldThrowInvalidOperationException_WhenGivenAmount_GreaterThanTheBalance() { int amountGreaterThatBalance = 20; int balance = 10; var sut = new Sut(balance); Assert.Throws <InvalidOperationException>(() => sut.Withdraw(amountGreaterThatBalance)); }
public void Deposit_ShouldAddToBalance_WithValueEqualToTheGivenAmount() { int depositAmount = 10; int balance = 20; var account = new Sut(balance); account.Deposit(depositAmount); Assert.AreEqual(balance + depositAmount, account.Balance); }
public void Withdraw_ShouldReduceBalance_WithTheGivenAmount() { int withdrawAmount = 10; int balance = 20; var account = new Sut(balance); account.Withdraw(withdrawAmount); Assert.AreEqual(balance - withdrawAmount, account.Balance); }
public BankAccount.BankAccount CreateAccount(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException($"{nameof(name)} must not be null or empty."); } var account = new BankAccount.BankAccount(name, this); this.sharedAccounts.Add(new UserBankAccount(account, this)); return(account); }