public void Deposit_CanMakeBasicDeposit() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Samie", CustomerId = 1, Accounts = new List <Account>() { new Account() { AccountId = 4, Balance = 600M } } } }; BankRepository.AddCustomers(customers); decimal amount = 200M; decimal expected = 800M; // Act var account = BankRepository.Deposit(4, amount); // Assert Assert.Equal(expected, account.Balance, 2); }
public void Deposit_CantDepositToNonExistingAccount() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Michael", CustomerId = 3, Accounts = new List <Account>() { new Account() { AccountId = 3, Balance = 600M } } } }; BankRepository.AddCustomers(customers); decimal amount = 200M; string expected = BankRepository.AccountDoesNotExist; // Act BankRepository.Deposit(1, amount); // Assert Assert.Equal(expected, BankRepository.ErrorMessage); }
public void Withdrawal_CantWithdrawFromNonExistingAccount() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Samie", CustomerId = 1, Accounts = new List <Account>() { new Account() { AccountId = 3, Balance = 500M } } } }; BankRepository.AddCustomers(customers); decimal amount = 100M; string expected = BankRepository.AccountDoesNotExist; // Act BankRepository.Withdrawal(1, amount); // Assert Assert.Equal(expected, BankRepository.ErrorMessage); }
public void Deposit_CantDepositNegativeAmount() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Robert", CustomerId = 2, Accounts = new List <Account>() { new Account() { AccountId = 5, Balance = 600M } } } }; BankRepository.AddCustomers(customers); decimal amount = -200M; decimal expected = 600M; // Act var account = BankRepository.Deposit(5, amount); // Assert Assert.Equal(expected, account.Balance, 2); }
public void WithdrawalOverDraft() { var customers = new List <Customer>() { new Customer() { Name = "Samie", CustomerId = 1, Accounts = new List <Account>() { new Account() { AccountId = 1, Balance = 700M } } } }; BankRepository.AddCustomers(customers); decimal amount = 900M; decimal expected = 700M; var actualAccount = BankRepository.Withdrawal(1, amount); Assert.Equal(expected, actualAccount.Balance, 2); }
public void Withdrawal_CantWithdrawMoreThanBalance() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Hannibal", Id = 1, Accounts = new List <Account>() { new Account() { AccountId = 1, Balance = 400M } } } }; BankRepository.AddCustomers(customers); decimal amount = 500M; decimal expected = 400M; // Act // customer id, account id, amount var actualAccount = BankRepository.Withdrawal(1, amount); // Assert Assert.Equal(expected, actualAccount.Balance, 2); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider services) { var customers = CreateCustomers(); BankRepository.AddCustomers(customers); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Withdrawal_CanMakeBasicWidthdrawal() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Hannibal", Id = 3, Accounts = new List <Account>() { new Account() { AccountId = 3, Balance = 600M } } } }; BankRepository.AddCustomers(customers); decimal amount = 200M; decimal expected = 400M; // Act var account = BankRepository.Withdrawal(3, amount); // Assert Assert.Equal(expected, account.Balance, 2); }
public void Withdrawal_CantWithdrawFromNonExistingAccount() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Hannibal", Id = 3, Accounts = new List <Account>() { new Account() { AccountId = 3, Balance = 600M } } } }; BankRepository.AddCustomers(customers); decimal amount = 200M; string expected = BankRepository.CantAccessNonExistingAccount; // Act BankRepository.Withdrawal(1, amount); // Assert Assert.Equal(expected, BankRepository.ErrorMessage); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); var customers = CreateCustomers(); BankRepository.AddCustomers(customers); }
public static void Create() { var gabriel = new Customer { Id = 1, Name = "Gabriel", Account = new Account(1, 500) }; var amanda = new Customer { Id = 2, Name = "Amanda", Account = new Account(2, 1500) }; var max = new Customer { Id = 3, Name = "Max", Account = new Account(3, 2500) }; var ronnehag = new Customer { Id = 4, Name = "Ronnehag", Account = new Account(4, 2500) }; var customers = new List <Customer> { gabriel, amanda, max, ronnehag }; BankRepository.AddCustomers(customers); }
public void Transfer() { // Arrange var customers = new List <Customer>() { new Customer() { Name = "Hannibal", Id = 5, Accounts = new List <Account>() { new Account() { AccountId = 5, Balance = 600M } } }, new Customer() { Name = "Michael", Id = 6, Accounts = new List <Account>() { new Account() { AccountId = 6, Balance = 700M } } } }; BankRepository.AddCustomers(customers); decimal amount = 200M; decimal expected = 900M; // Act var account = BankRepository.Transfer(amount, 5, 6); var accountB = BankRepository.GetAccounts().Find(x => x.AccountId == 6); // Assert Assert.Equal(expected, accountB.Balance); }