コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        /// <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));
        }
コード例 #4
0
ファイル: AccountManager.cs プロジェクト: CarlosVV/mediavf
 /// <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);
 }
コード例 #5
0
ファイル: AccountsService.cs プロジェクト: CarlosVV/mediavf
 /// <summary>
 /// Gets all accounts
 /// </summary>
 /// <returns></returns>
 public IEnumerable <CashAccount> GetAccounts()
 {
     using (var repository = _repositoryFactory.CreateRepository())
         return(repository.CashAccountsQuery.ToList());
 }