public void Initialize() { _settings = A.Fake<IAccountManagementSettings>(); A.CallTo(() => _settings.FinalizedTransactionLifetime).Returns(TimeSpan.FromDays(7)); _transactionProcessor = A.Fake<ITransactionProcessor>(); _repositoryFactory = A.Fake<IAccountRepositoryFactory>(); _repository = A.Fake<IAccountRepository>(); A.CallTo(() => _repositoryFactory.CreateRepository()).Returns(_repository); _account = new CashAccount(); _accountManager = new AccountManager(_settings, _transactionProcessor, _repositoryFactory, _account); }
public void Initialize() { _settings = A.Fake <IAccountManagementSettings>(); A.CallTo(() => _settings.FinalizedTransactionLifetime).Returns(TimeSpan.FromDays(7)); _transactionProcessor = A.Fake <ITransactionProcessor>(); _repositoryFactory = A.Fake <IAccountRepositoryFactory>(); _repository = A.Fake <IAccountRepository>(); A.CallTo(() => _repositoryFactory.CreateRepository()).Returns(_repository); _account = new CashAccount(); _accountManager = new AccountManager(_settings, _transactionProcessor, _repositoryFactory, _account); }
/// <summary> /// Gets the manager for an account /// </summary> /// <param name="accountId"></param> /// <returns></returns> public IAccountManager GetManagerForAccount(int accountId) { // get the account CashAccount account; using (var repository = _accountRepositoryFactory.CreateRepository()) account = repository.CashAccountsQuery.FirstOrDefault(a => a.Id == accountId); // throw exception indicating the account was not found if (account == null) { throw new AccountNotFoundException(accountId); } // create manager for account data return(_accountManagerFactory.CreateAccountManager(account)); }
/// <summary> /// Reserves funds /// </summary> /// <param name="reservationKey"></param> /// <param name="amount"></param> /// <param name="timeToReserve"></param> /// <returns></returns> public void Reserve(Guid reservationKey, decimal amount, TimeSpan?timeToReserve = null) { lock (_accessLock) using (var repository = _repositoryFactory.CreateRepository()) repository.CreateFundReservation(_account.Id, reservationKey, amount, timeToReserve); }
/// <summary> /// Gets all accounts /// </summary> /// <returns></returns> public IEnumerable <CashAccount> GetAccounts() { using (var repository = _repositoryFactory.CreateRepository()) return(repository.CashAccountsQuery.ToList()); }