public decimal GetCashFlowTransactionsSumByFilter(CashFlowTransactionsFilter filter)
        {
            string securityToken = _securityService.SecurityToken;
            InvestmentDefaultProcessToken investmentToken = _investmentsRepository
                                                            .GetTokenForInvestmentDefaultProcess(InvestmentsProcessDirection.In, filter.MaxTokens, false, MaxAmount);

            if (!investmentToken.IsValidUserNameAndCredentials)
            {
                throw new InvalidOperationException();
            }

            IEnumerable <AccountingInvestmentValidationCriteria> criteria =
                _accountingCriteriaFactory.CreateAccountingCriteria(AccountingEntityType.Cashflow, investmentToken.Steps, investmentToken, securityToken);

            if (criteria.Count() != ExpectedCriteriaCount)
            {
                throw new InvalidOperationException();
            }

            if (criteria.Any(c => c.RequestHashCode <= 0))
            {
                throw new InvalidOperationException();
            }

            var cashflow = criteria.Select(_accountingRepository.GetCashFlowByCriteria).ToList();

            decimal delta;

            _moneyValidator.ValidateAndGetDelta(cashflow, out delta);

            return(cashflow.Sum() + delta);
        }
Exemple #2
0
        public void Sample_MethodResultSimplifiedNames2()
        {
            dynamic accountingCriteriaFactory = new DynamicMock();

            accountingCriteriaFactory.Create_Criteria(_, _, _, _)
            .Returns(new[] { new { _Code = 1 }, new { _Code = 2 }, new { _Code = 3 } });

            IAccountingCriteriaFactory result = accountingCriteriaFactory;

            var actual = result.CreateAccountingCriteria(AccountingEntityType.Cashflow, new decimal[0], null, "");

            CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, actual.Select(c => c.RequestHashCode).ToList());
        }