public void Lock_Account_Locks_The_Given_Account() { /* * Arrange * 1º - Create a fake data * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ string accountNumber = "EX325"; BankAccount account = new BankAccount() { BankAccountNumber = accountNumber, Locked = false }; SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.FindBankAccountByNumberString = accNumber => account; bankingService.ChangeBankAccountBankAccount = bankAccount => { }; BankAccountController controller = new BankAccountController(bankingService); //Act RedirectToRouteResult result = controller.LockAccount(accountNumber) as RedirectToRouteResult; //Assert Assert.IsNotNull(result, "Expected a RedirectToRouteResult"); Assert.AreEqual("TransferMoney", result.RouteValues["action"], "Expected a redirection to TransferMoney"); }
public void Transfer_Money_Performs_The_Transfer_Of_The_Given_Amount_Between_The_Given_Accounts() { /* * Arrange * 1º - Create a fake data * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ decimal transferAmount = 50; string sourceAccount = "eX325"; string targetAccount = "eX287"; SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.PerformTransferStringStringDecimal = (source, target, amount) => { }; BankAccountController controller = new BankAccountController(bankingService); //Act RedirectToRouteResult result = controller.TransferMoney(sourceAccount, targetAccount, transferAmount) as RedirectToRouteResult; //Assert Assert.IsNotNull(result, "Expected a RedirectToRouteResult"); Assert.AreEqual("TransferMoney", result.RouteValues["action"], "Expected a redirection to TransferMoney"); }
public void Transfer_Money_Shows_A_List_Of_Bank_Accounts() { /* * Arrange * 1º - Create a dummy list of transfers * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ IList <BankAccount> accounts = GetFakeBankAccounts(); SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.FindPagedBankAccountsInt32Int32 = (page, pageSize) => accounts.Skip(page * pageSize).Take(pageSize).ToList(); BankAccountController controller = new BankAccountController(bankingService); //Act ViewResultBase result = controller.TransferMoney() as ViewResult; //Assert Assert.IsNotNull(result); BankAccountListViewModel model = result.ViewData.Model as BankAccountListViewModel; Assert.IsNotNull(model); }
public void Index_Action_Returns_The_List_Of_Bank_Trasnfers() { /* * Arrange * 1º - Create a dummy list of transfers * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ IList <BankTransfer> transfers = GetFakeTransfers(); SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.FindBankTransfersInt32Int32 = (page, pageSize) => { return(transfers.Skip(page * pageSize).Take(pageSize).ToList()); }; BankAccountController controller = new BankAccountController(bankingService); //Act ViewResultBase result = controller.Index(0, 5) as ViewResult; //Assert Assert.IsNotNull(result, "The action result is null or is not an instance of ViewResult"); TransfersListViewModel model = result.ViewData.Model as TransfersListViewModel; Assert.IsNotNull(model, "The model is null or is not an instance of TransfersListViewModel"); IList <BankTransfer> modelTransfers = (model.PageItems as IEnumerable <BankTransfer>).ToList(); }
public void Index_Action_Returns_The_List_Of_Bank_Trasnfers() { /* * Arrange * 1º - Create a dummy list of transfers * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ IList<BankTransfer> transfers = GetFakeTransfers(); SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.FindBankTransfersInt32Int32 = (page, pageSize) => { return transfers.Skip(page * pageSize).Take(pageSize).ToList(); }; BankAccountController controller = new BankAccountController(bankingService); //Act ViewResultBase result = controller.Index(0, 5) as ViewResult; //Assert Assert.IsNotNull(result, "The action result is null or is not an instance of ViewResult"); TransfersListViewModel model = result.ViewData.Model as TransfersListViewModel; Assert.IsNotNull(model, "The model is null or is not an instance of TransfersListViewModel"); IList<BankTransfer> modelTransfers = (model.PageItems as IEnumerable<BankTransfer>).ToList(); }
public void Lock_Account_Locks_The_Given_Account() { /* * Arrange * 1º - Create a fake data * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ string accountNumber = "EX325"; BankAccount account = new BankAccount() { BankAccountNumber = accountNumber, Locked = false }; SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.FindBankAccountByNumberString = accNumber => account; bankingService.ChangeBankAccountBankAccount = bankAccount => { }; BankAccountController controller = new BankAccountController(bankingService); //Act RedirectToRouteResult result = controller.LockAccount(accountNumber) as RedirectToRouteResult; //Assert Assert.IsNotNull(result, "Expected a RedirectToRouteResult"); Assert.AreEqual("TransferMoney", result.RouteValues["action"], "Expected a redirection to TransferMoney"); }
public void Transfer_Money_Performs_The_Transfer_Of_The_Given_Amount_Between_The_Given_Accounts() { /* * Arrange * 1º - Create a fake data * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ decimal transferAmount = 50; string sourceAccount = "eX325"; string targetAccount = "eX287"; SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.PerformTransferStringStringDecimal = (source, target, amount) => { }; BankAccountController controller = new BankAccountController(bankingService); //Act RedirectToRouteResult result = controller.TransferMoney(sourceAccount, targetAccount, transferAmount) as RedirectToRouteResult; //Assert Assert.IsNotNull(result, "Expected a RedirectToRouteResult"); Assert.AreEqual("TransferMoney", result.RouteValues["action"], "Expected a redirection to TransferMoney"); }
public void Transfer_Money_Shows_A_List_Of_Bank_Accounts() { /* * Arrange * 1º - Create a dummy list of transfers * 2º - Initialize stub of IBankingManagementService * 3º - Create controller to test */ IList<BankAccount> accounts = GetFakeBankAccounts(); SIBankingManagementService bankingService = new SIBankingManagementService(); bankingService.FindPagedBankAccountsInt32Int32 = (page, pageSize) => accounts.Skip(page * pageSize).Take(pageSize).ToList(); BankAccountController controller = new BankAccountController(bankingService); //Act ViewResultBase result = controller.TransferMoney() as ViewResult; //Assert Assert.IsNotNull(result); BankAccountListViewModel model = result.ViewData.Model as BankAccountListViewModel; Assert.IsNotNull(model); }