コード例 #1
0
        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);
        }
コード例 #2
0
        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.");
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        public void TestInsertReturnsError()
        {
            CrudProxy proxy = new TransactionCategoryProxy();
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Asset, "For TestInsertReturnsError");
            proxy.Insert(dto);

            //
            //	Set the uid to 0 - and re-insert
            //
            dto.Uid = 0;
            try
            {
                proxy.Insert(dto);
                throw new Exception("Exception expected.");
            }
            catch(RestException ex)
            {
                Assert.AreEqual("DuplicateNameException", ex.Type, "Incorrect error type.");
            }
        }
コード例 #7
0
        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);
        }