コード例 #1
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);
            }
        }
コード例 #2
0
        public void TestUpdate()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Income, "For Testing Update");

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

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

            dto.Name += " - Post Update";
            proxy.Update(dto);

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

            AssertEqual(dto, fromOla, false);
            Assert.AreEqual(fromOla.Level, Constants.AccountLevel.Detail);
        }