static void Main(string[] args) { var sortCode = "11-11-11"; var accountNumber = 23456789; var query = new GetCurrentAccountQuery(sortCode, accountNumber); var currentAccount = getCurrentAccount(query); Console.WriteLine("{0} {1}", currentAccount.FirstName, currentAccount.LastName); var transactionQuery = new GetCurrentAccountTransactionsQuery(sortCode, accountNumber); var transactions = getCurrentAccountTransactions(transactionQuery); foreach (var item in transactions) Console.WriteLine("[{0}] {1} -> {2:C}", item.TransactionType, item.TransactionDate, item.Amount); Console.ReadLine(); }
public void should_return_current_account_if_account_exists() { // Arrange var currentAccount = new CurrentAccountBuilder() .Build(); var query = new GetCurrentAccountQuery(currentAccount.SortCode, currentAccount.AccountNumber); var dataService = Substitute.For<IDataService>(); dataService.GetCurrentAccount(currentAccount.SortCode, currentAccount.AccountNumber) .Returns(currentAccount); var sut = new GetCurrentAccountQueryHandlerBuilder() .WithDataService(dataService) .Build(); // Act var actual = sut.Handle(query); // Assert Assert.That(actual, Is.Not.Null); Assert.That(new CurrentAccountComparer().Equals(actual, currentAccount)); }
private static CurrentAccount getCurrentAccount(GetCurrentAccountQuery query) { var handler = new GetCurrentAccountQueryHandler(new DataService()); return handler.Handle(query); }