Exemplo n.º 1
0
        public void IsOverdraftAlgorithm_Detects_Overdrafts()
        {
            int expectedCount = 1;
            int actualCount   = 0;

            // -----
            // ARRANGE
            Builder.LoadDataScenario(UnitOfWork, DataScenarios.Default);
            Builder.LoadDataScenario(UnitOfWork, DataScenarios.Overdrafts);

            var algorithm = new IsOverdraftAlgorithm();
            var entities  = UnitOfWork.BankAccounts.GetAll().ToList();

            // -----
            // ACT
            entities.ForEach(e => {
                IAlgorithmResult calculation = algorithm.Calculate(e.Balance);

                if (calculation.Result)
                {
                    actualCount++;
                }
            });

            // -----
            // ASSERT
            Assert.AreEqual(expectedCount, actualCount);
        }
Exemplo n.º 2
0
        public IEnumerable <BankAccount> FindOverdrafts(IAccountAlgorithm overdraftAlgorithm)
        {
            TraceHandler.TraceIn(TraceLevel.Info);

            var accounts = new List <BankAccount>();

            try
            {
                var entities = UnitOfWork.BankAccounts.GetAll().ToList();

                entities.ForEach(e => {
                    IAlgorithmResult calculation = overdraftAlgorithm.Calculate(e.Balance);

                    if (calculation.Result)
                    {
                        accounts.Add(e);
                    }
                });
            }
            catch (Exception ex)
            {
                TraceHandler.TraceError(ex);
            }
            finally
            {
                TraceHandler.TraceOut();
            }

            return(accounts.AsEnumerable());
        }