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); }