public void VipAccount_Create_Succeeds() { var account = new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345678" }; var existingAccounts = new List <Account> { new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345679" }, new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345670" } }; Assert.True(_accountDomainService.CanCreateAccount(account, existingAccounts)); }
public static void AddAccount() { Console.WriteLine("choose account type:"); Console.WriteLine("1. Simple Account"); Console.WriteLine("2. VIP Account"); int accountType = int.Parse(Console.ReadLine()); Console.WriteLine("enter an ID number for the account"); int id = int.Parse(Console.ReadLine()); IAccount newAccount; switch (accountType) { case 1: newAccount = new SimpleAccount(id); break; case 2: newAccount = new VipAccount(id); break; default: throw new Exception("Wrong Account Type"); } if (accounts.Contains(newAccount)) { Console.WriteLine("account already exists"); } else { accounts.Add(newAccount); } string message; if (accountType == 1) { message = "Simple Account added ID " + id; } else { message = "VIP Account added ID: " + id; } try { log.WriteEntry(new LogEntry() { Message = message }); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); Environment.Exit(1); } }
public void VipAccount_Create_5AccountsAlreadyExist_Fails() { var account = new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345678" }; var existingAccounts = new List <Account> { new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345679" }, new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345670" }, new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345671" }, new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012145671" }, new VipAccount { CustomerId = 1, Balance = 1000, Number = "LT123456789012345671" } }; Assert.Throws <BusinessException>(() => _accountDomainService.CanCreateAccount(account, existingAccounts)); }