public virtual void Init() { var accountRepository = new AccountRepositoryStub(); var transactionRepository = new TransactionRepositoryStub(); RulesService = new BusinessRulesService(); BankService = new BankService(accountRepository, transactionRepository, RulesService); User = CreateUser(); }
protected User CreateUser() { var user = new User { FirstName = "John", LastName = "Johnson" }; return user; }
/// <summary> /// Creates a new account /// </summary> /// <param name="user"><see cref="User"/> entity</param> /// <returns>Created <see cref="Account"/> entity</returns> public Account CreateAccount(User user) { if (user == null) throw new ArgumentNullException("user"); var account = new Account { Balance = 0m, User = user }; _accountRepository.Add(account); return account; }
/// <summary> /// Gets all accounts for the user /// </summary> /// <param name="user"><see cref="User"/> entity</param> /// <returns>Collection of the <see cref="Account"/> entities for the user</returns> public IEnumerable<Account> GetAccountsForUser(User user) { if (user == null) throw new ArgumentNullException("user"); var accounts = _accountRepository.GetAccountsForUser(user); return accounts; }