Exemplo n.º 1
0
        public void TestIntialise()
        {
            this.mockRuleService = new Mock <ITransactionRuleService>(MockBehavior.Strict);
            this.mockReconciliationConsistency = new Mock <IReconciliationConsistency>();
            this.bucketRepo            = new BucketBucketRepoAlwaysFind();
            this.testDataBudgets       = BudgetModelTestData.CreateCollectionWith1And2();
            this.testDataBudgetContext = new BudgetCurrencyContext(this.testDataBudgets, this.testDataBudgets.CurrentActiveBudget);
            this.testDataStatement     = new StatementModelBuilder()
                                         .TestData5()
                                         .AppendTransaction(new Transaction
            {
                Account         = StatementModelTestData.ChequeAccount,
                Amount          = -23.56M,
                BudgetBucket    = StatementModelTestData.RegoBucket,
                Date            = ReconcileDate.Date.AddDays(-1),
                TransactionType = new NamedTransaction("Foo"),
                Description     = "Last transaction"
            })
                                         .Build();
            this.testDataToDoList = new List <ToDoTask>();
            this.subject          = new ReconciliationCreationManager(this.mockRuleService.Object, this.mockReconciliationConsistency.Object, new FakeLogger());

            this.testDataLedgerBook = LedgerBookTestData.TestData5(() => new LedgerBookTestHarness(new Mock <IReconciliationBuilder>().Object));

            this.mockReconciliationConsistency.Setup(m => m.EnsureConsistency(It.IsAny <LedgerBook>())).Returns(new Mock <IDisposable>().Object);
        }
Exemplo n.º 2
0
        public void TestIntialise()
        {
            this.mockBucketRepo  = new Mock <IBudgetBucketRepository>();
            this.mockRuleService = new Mock <ITransactionRuleService>();
            this.mockReconciliationConsistency = new Mock <IReconciliationConsistency>();
            this.subject = new ReconciliationCreationManager(this.mockRuleService.Object, this.mockReconciliationConsistency.Object, new FakeLogger());

            this.testDataLedgerBook = LedgerBookTestData.TestData5(() => new LedgerBookTestHarness(new Mock <IReconciliationBuilder>().Object));
            this.testDataEntryLine  = this.testDataLedgerBook.Reconciliations.First();
            this.testDataEntryLine.Unlock();

            this.surplusChqLedger = new SurplusLedger {
                StoredInAccount = StatementModelTestData.ChequeAccount
            };
            this.insHomeSavLedger = this.testDataLedgerBook.Ledgers.Single(l => l.BudgetBucket == StatementModelTestData.InsHomeBucket);
            this.phNetChqLedger   = this.testDataLedgerBook.Ledgers.Single(l => l.BudgetBucket == StatementModelTestData.PhoneBucket);
        }
        private void ActOnTestData5(StatementModel statementModelTestData = null)
        {
            this.subject           = LedgerBookTestData.TestData5();
            this.testDataBudget    = BudgetModelTestData.CreateTestData5();
            this.testDataStatement = statementModelTestData ?? StatementModelTestData.TestData5();

            Console.WriteLine("********************** BEFORE RUNNING RECONCILIATION *******************************");
            this.testDataStatement.Output(ReconcileDate.AddMonths(-1));
            this.subject.Output(true);

            var result = Act(bankBalances: new[] { new BankBalance(StatementModelTestData.ChequeAccount, 1850.5M), new BankBalance(StatementModelTestData.SavingsAccount, 1200M) });

            this.testDataToDoList = result.Tasks.ToList();

            Console.WriteLine();
            Console.WriteLine("********************** AFTER RUNNING RECONCILIATION *******************************");
            this.subject.Output(true);
        }
        public void Reconcile_WithPaymentFromWrongAccountShouldUpdateLedgerBalance_GivenTestData5()
        {
            this.testDataBudget = BudgetModelTestData.CreateTestData5();
            this.subject        = LedgerBookTestData.TestData5();
            var testTransaction = this.testDataStatement.AllTransactions.Last();

            testTransaction.BudgetBucket = LedgerBookTestData.HouseInsLedgerSavingsAccount.BudgetBucket;
            testTransaction.Account      = StatementModelTestData.ChequeAccount;
            testTransaction.Amount       = -1250;
            this.testDataStatement.Output(DateTime.MinValue);
            this.subject.Output();

            var reconResult = Act(bankBalances: new[] { new BankBalance(StatementModelTestData.ChequeAccount, 1850.5M), new BankBalance(StatementModelTestData.SavingsAccount, 1000M) });

            this.subject.Output(true);

            Assert.AreEqual(300M, reconResult.Reconciliation.Entries.Single(e => e.LedgerBucket == LedgerBookTestData.HouseInsLedgerSavingsAccount).Balance);
        }
Exemplo n.º 5
0
        private void ActOnTestData5(StatementModel statementModelTestData = null, bool ignoreWarnings = false)
        {
            this.testDataLedgerBook    = LedgerBookTestData.TestData5(() => new LedgerBookTestHarness(new Mock <IReconciliationBuilder>().Object));
            this.testDataBudgets       = new BudgetCollection(new[] { BudgetModelTestData.CreateTestData5() });
            this.testDataBudgetContext = new BudgetCurrencyContext(this.testDataBudgets, this.testDataBudgets.CurrentActiveBudget);
            this.testDataStatement     = statementModelTestData ?? StatementModelTestData.TestData5();

            Console.WriteLine("********************** BEFORE RUNNING RECONCILIATION *******************************");
            this.testDataStatement.Output(ReconcileDate.AddMonths(-1));
            this.testDataLedgerBook.Output(true);

            Act(bankBalances: new[] { new BankBalance(StatementModelTestData.ChequeAccount, 1850.5M), new BankBalance(StatementModelTestData.SavingsAccount, 1200M) },
                ignoreWarnings: ignoreWarnings);

            Console.WriteLine();
            Console.WriteLine("********************** AFTER RUNNING RECONCILIATION *******************************");
            this.testDataLedgerBook.Output(true);
        }
        public void Reconcile_WithPaymentFromWrongAccountShouldCreateBalanceAdjustment_GivenTestData5()
        {
            this.testDataBudget.Output();
            this.subject = LedgerBookTestData.TestData5();
            var testTransaction = this.testDataStatement.AllTransactions.Last();

            testTransaction.BudgetBucket = LedgerBookTestData.HouseInsLedgerSavingsAccount.BudgetBucket;
            testTransaction.Account      = StatementModelTestData.ChequeAccount;
            this.testDataStatement.Output(DateTime.MinValue);
            this.subject.Output();

            var reconResult = Act(bankBalances: new[] { new BankBalance(StatementModelTestData.ChequeAccount, 1850.5M), new BankBalance(StatementModelTestData.SavingsAccount, 1000M) });

            this.subject.Output(true);

            var savingsBal = reconResult.Reconciliation.BankBalances.Single(b => b.Account == LedgerBookTestData.SavingsAccount).Balance
                             + reconResult.Reconciliation.BankBalanceAdjustments.Where(b => b.BankAccount == LedgerBookTestData.SavingsAccount).Sum(b => b.Amount);
            var chqBal = reconResult.Reconciliation.BankBalances.Single(b => b.Account == LedgerBookTestData.ChequeAccount).Balance
                         + reconResult.Reconciliation.BankBalanceAdjustments.Where(b => b.BankAccount == LedgerBookTestData.ChequeAccount).Sum(b => b.Amount);

            Assert.AreEqual(650M, savingsBal, "Savings should be decreased because savings still has the funds and needs to payback the Cheque account.");
            Assert.AreEqual(2200.50M, chqBal, "Chq should be increased after it has been paid back from savings.");
            Assert.AreEqual(0M, reconResult.Reconciliation.TotalBalanceAdjustments);
        }
 public void OutputTestData5()
 {
     LedgerBookTestData.TestData5().Output(true);
 }
Exemplo n.º 8
0
 private LedgerEntryLine CreateSubject()
 {
     return(LedgerBookTestData.TestData5().Reconciliations.First());
 }