public void TestInsertAndGetDetailAccountWithHeaderAccountAssigned()
        {
            //set up header account first.
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Expense, "Header Account For Detail");

            dto.Level          = Constants.AccountLevel.Header;
            dto.DefaultTaxCode = null;

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");
            var headerAccountUid = dto.Uid;

            //set up a detail account with the above header account assigned to it.
            dto                  = GetNewTransactionCategory(AccountType.Expense, "Detail with Header");
            dto.Level            = Constants.AccountLevel.Detail;
            dto.HeaderAccountUid = headerAccountUid;
            proxy.Insert(dto);

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla);
        }
        public void TestInsertAndGet()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Income, "For Testing Insert And Get");

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla, false);
            Assert.AreEqual(fromOla.Level, Constants.AccountLevel.Detail);
        }
        public void TestInsertAndGetHeaderAccount()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Income, "For Testing Insert And Get Header");

            dto.Level          = Constants.AccountLevel.Header;
            dto.DefaultTaxCode = null;

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla);
        }
        public void TestInsertAndGetLoanForBackwardCompatibility()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory("Loan", "For Testing Insert And Get Loan Account");

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            dto.Type = AccountType.Liability;

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla, false);
            Assert.AreEqual(fromOla.Level, Constants.AccountLevel.Detail);
        }
        public void TestDelete()
        {
            CrudProxy proxy = new TransactionCategoryProxy();

            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Liability, "TestDelete");

            proxy.Insert(dto);

            proxy.DeleteByUid(dto.Uid);

            try
            {
                proxy.GetByUid(dto.Uid);
                throw new Exception("Exception expected.");
            }
            catch (RestException ex)
            {
                Assert.AreEqual("RecordNotFoundException", ex.Type, "Incorrect error type.");
            }
        }
        public void TestUpdateResultingInRecordHasChangedException()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Income, "For TestUpdateResultingInRecordHasChangedException");

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            int    uid            = dto.Uid;
            string lastUpdatedUid = dto.LastUpdatedUid;

            dto.Name = this.TestUid + "For TestUpdateSyncCheckError - Updated";
            proxy.Update(dto);

            //
            //	Ensure last updated uid is different
            //
            Assert.IsTrue(lastUpdatedUid != dto.LastUpdatedUid, "The LastUpdatedUid should have been updated (1).");

            TransactionCategoryDto dto2 = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            Assert.IsTrue(lastUpdatedUid != dto.LastUpdatedUid, "The LastUpdatedUid should have been updated (2).");

            dto.LastUpdatedUid = lastUpdatedUid;
            dto.Type           = AccountType.OtherIncome;

            try
            {
                proxy.Update(dto);
                throw new Exception("The expected exception is not thrown.");
            }
            catch (RestException ex)
            {
                //	This was expected.
                Assert.AreEqual("RecordHasChangedException", ex.Type);
            }
        }