/// <summary>
        ///     Makes sure that the IsNew property on LedgerBook EntryLines is not set to true, as it will be when they are newly
        ///     created.
        ///     Also ensures the StoredInAccount property for each ledger is set.
        /// </summary>
        internal static void Finalise(LedgerBook book, bool unlock = false)
        {
            if (book.Reconciliations.None())
            {
                return;
            }
            var ledgers = new Dictionary <BudgetBucket, LedgerBucket>();

            foreach (LedgerEntryLine line in book.Reconciliations)
            {
                if (!unlock)
                {
                    PrivateAccessor.SetProperty(line, "IsNew", false);
                }
                foreach (LedgerEntry entry in line.Entries)
                {
                    if (!unlock)
                    {
                        PrivateAccessor.SetField(entry, "isNew", false);
                    }
                    if (entry.LedgerBucket.StoredInAccount == null)
                    {
                        entry.LedgerBucket.StoredInAccount = StatementModelTestData.ChequeAccount;
                    }
                    if (!ledgers.ContainsKey(entry.LedgerBucket.BudgetBucket))
                    {
                        ledgers.Add(entry.LedgerBucket.BudgetBucket, entry.LedgerBucket);
                    }
                }
            }

            book.Ledgers = ledgers.Values;
        }
        public void TestInitialise()
        {
            this.testData = new FixedBudgetProjectBucket(FixedProjectCode, "Foo bar dum-de-dum", 1000);
            PrivateAccessor.SetProperty(this.testData, "Created", this.testDataCreatedDate);

            var subject = new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory());

            this.result = subject.ToDto(this.testData);
        }
Пример #3
0
        public void PrivateAccessor_ShouldGetSetProperty()
        {
            // ACT
            // Wrapping the instance holding the private property.
            var inst = new PrivateAccessor(new ClassWithNonPublicMembers());

            // Setting the value of the private property.
            inst.SetProperty("Prop", 555);

            // ASSERT - Asserting with getting the value of the private property.
            Assert.AreEqual(555, inst.GetProperty("Prop"));
        }
Пример #4
0
        public void TestInitialise()
        {
            var todoCollection = new ToDoCollection();

            todoCollection.Add(new ToDoTask("Foo1"));
            todoCollection.Add(new ToDoTask("Foo2", false, false));
            this.testData = new ApplicationDatabase();
            PrivateAccessor.SetProperty(this.testData, "BudgetCollectionStorageKey", "Budget.xml");
            PrivateAccessor.SetProperty(this.testData, "FileName", "C:\\Foo\\TestData.bax");
            PrivateAccessor.SetProperty(this.testData, "LedgerBookStorageKey", "Ledger.xml");
            PrivateAccessor.SetProperty(this.testData, "MatchingRulesCollectionStorageKey", "Rules.xml");
            PrivateAccessor.SetProperty(this.testData, "StatementModelStorageKey", "Statement.xml");
            PrivateAccessor.SetProperty(this.testData, "LedgerReconciliationToDoCollection", todoCollection);

            var subject = new Mapper_BudgetAnalyserStorageRoot_ApplicationDatabase();

            this.result = subject.ToDto(this.testData);
        }
Пример #5
0
        public void TestInit()
        {
            PrivateAccessor.SetProperty(this.testAppDb, "StatementModelStorageKey", @"Foo.csv");
            PrivateAccessor.SetProperty(this.testAppDb, "FileName", @"C:\AppDb.bax");
            this.testData = StatementModelTestData.TestData2();

            this.mockBudgetBucketRepo = new Mock <IBudgetBucketRepository>();
            this.mockStatementRepo    = new Mock <IStatementRepository>();

            this.mockStatementRepo.Setup(m => m.LoadAsync(It.IsAny <string>(), It.IsAny <bool>()))
            .Returns(Task.FromResult(this.testData))
            .Verifiable();

            this.mockBudgetBucketRepo
            .Setup(m => m.Buckets)
            .Returns(BudgetBucketTestData.BudgetModelTestData1Buckets);

            this.budgetBucketRepo = this.mockBudgetBucketRepo.Object;
            Arrange();
        }
 internal static LedgerEntryLine SetEntriesForTesting(this LedgerEntryLine line, List <LedgerEntry> entries)
 {
     PrivateAccessor.SetProperty(line, "Entries", entries);
     return(line);
 }