Beispiel #1
0
        public void ARProxy_Transacation_Simple_Rollback()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                context.TransactionBegin();
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status         = NRemedy_Test_Regular_Form.Status_Enum.Fixed
                });
                Assert.AreEqual(string.Empty, entryId);
                //second call will failed
                List <ARFieldValue> up_fvs = new List <ARFieldValue>();
                up_fvs.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR));
                proxy.SetEntry("11111111111", up_fvs);

                var result = context.TransactionCommit();

                Assert.IsFalse(result.Success);
                Assert.AreEqual(2, result.ResultList.Count);

                Assert.AreEqual(EntryCallType.BULK_ENTRY_CREATE, result.ResultList[0].CallType);
                var entryid1 = result.ResultList[0].EntryId;
                //!!@@important
                //when create entry is not in trasaction, it will not cause warning 52 when the RequestID is in the fieldValueList
                //but in trasacation, this will cause warning 52.
                //this because trasaction actually means group the operations and send to AR when commit.AR may block the operaion,
                //even this is caused by warning
                Assert.IsNull(result.ResultList[0].Status);

                Assert.AreEqual(EntryCallType.BULK_ENTRY_SET, result.ResultList[1].CallType);
                Assert.IsNotNull(result.ResultList[1].Status);
                //item do not exist in the db
                Assert.AreEqual(302, result.ResultList[1].Status.MessageNumber);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }