public static void Initialize(TestContext context2)
 {
     ARLoginContext context = null;
     try
     {
         context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
         //int totalMatch = -1;
         ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
         var models = proxy.GetEntryList(
             null,
             new string[]{ "RequestID" },
             null,
             0,
             null,
             null);
         foreach (var model in models)
         {
             proxy.DeleteEntry(model);
         }
     }
     catch(Exception ex)
     {
         throw new Exception("env init in Construct error.", ex);
     }
     finally
     {
         context.Dispose();
     }
 }
示例#2
0
        public static void Initialize(TestContext context2)
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                //int totalMatch = -1;
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                var models = proxy.GetEntryList(
                    null,
                    new string[] { "RequestID" },
                    null,
                    0,
                    null,
                    null);
                foreach (var model in models)
                {
                    proxy.DeleteEntry(model);
                }

                NRemedy_Test_Regular_Form newentry = new NRemedy_Test_Regular_Form();
                newentry.CharacterField = TestCharacterFieldValue;
                newentry.Radio_Button_Field = null;
                newentry.IntegerField = 1;
                for (int i = 0; i < 7; i++)
                {
                    proxy.CreateEntry(newentry);
                }

                newentry.CharacterField = TestCharacterFieldValueChinese;
                newentry.IntegerField = 2;
                for (int i = 0; i < 9; i++)
                {
                    proxy.CreateEntry(newentry);
                }

                newentry.CharacterField = TestCharacterFieldValueChinese + "Set Something";
                newentry.IntegerField = 3;
                for (int i = 0; i < 2; i++)
                {
                    proxy.CreateEntry(newentry);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("env init in Construct error.", ex);
            }
            finally
            {
                context.Dispose();
            }
        }
        public void ARProxy_CreateEntry_datatype_character_chinese_with_delete()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = TestCharacterFieldValueChinese
                });
                Assert.AreNotEqual(null, entryId);

                //GetEntry
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(TestCharacterFieldValueChinese,  model.CharacterField);

                //DeleteEntry
                proxy.DeleteEntry(model);

                //GetAgain
                model = proxy.GetEntry(entryId);
                Assert.IsNull(model);

                //DeleteAgain
                proxy.DeleteEntry(entryId);
            }
            catch (ARException ex)
            {
                Assert.AreEqual(null, ex);

            }
            finally
            {
                context.Dispose();
            }
        }
示例#4
0
 public void Login_with_admin_success()
 {
     ARLoginContext context = null;
     try
     {
         //login will be perform in the construct of ARLoginContext
         context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
     }
     catch (Exception ex)
     {
         Assert.AreEqual(null, ex);
     }
     finally
     {
         if(context != null)
             context.Dispose();
     }
 }
示例#5
0
 public void Login_with_admin_failed_cause_bad_user()
 {
     ARLoginContext context = null;
     try
     {
         context = new ARLoginContext(TestServer, TestAdmin + "something", TestAdminPwd);
     }
     catch (ARException ex)
     {
         Assert.AreEqual(623, ex.MessageNumber); //183977-ErrorMsgs-7604.pdf page  72
     }
     finally
     {
         if(context != null)
             context.Dispose();
     }
 }
        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();
            }
        }
        public void ARProxy_SetEntry_By_Properties_Str()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField = 10
                }
                );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                //Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                model.CharacterField = "don not want changed";
                model.Status = NRemedy_Test_Regular_Form.Status_Enum.New;
                model.DecimalNumberField = 3.14m;
                model.IntegerField = 11;

                //set
                proxy.SetEntry(model, new string[] {
                    "Status",
                    "DecimalNumberField",
                    "IntegerField"
                });

                NRemedy_Test_Regular_Form model2 = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.New, model2.Status);
                Assert.AreEqual(3.14m, model2.DecimalNumberField);
                Assert.AreEqual(11, model2.IntegerField);
                Assert.AreEqual("should not changed", model2.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
        public void ARProxy_SetEntry_By_Properties_Ids()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField = 10
                }
                );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                //Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                model.CharacterField = "don not want changed";
                model.Status = NRemedy_Test_Regular_Form.Status_Enum.New;
                model.DecimalNumberField = 3.14m;
                model.IntegerField = 11;

                List<ARFieldValue> up_fvs = new List<ARFieldValue>();

                up_fvs.Add(new ARFieldValue(TestDecimalFieldId, 3.14m, ARDataType.DATA_TYPE_DECIMAL));
                up_fvs.Add(new ARFieldValue(7u, NRemedy_Test_Regular_Form.Status_Enum.New, ARDataType.DATA_TYPE_ENUM));
                up_fvs.Add(new ARFieldValue(TestIntFieldId, 11, ARDataType.DATA_TYPE_INTEGER));

                //set
                proxy.SetEntry(entryId, up_fvs);

                NRemedy_Test_Regular_Form model2 = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.New, model2.Status);
                Assert.AreEqual(3.14m, model2.DecimalNumberField);
                Assert.AreEqual(11, model2.IntegerField);
                Assert.AreEqual("should not changed", model2.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
        public void ARProxy_CreateEntry_datatype_datetime()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    DateTimeField = dt
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);

                Assert.AreEqual(dt.Year, ((DateTime)model.DateTimeField).Year);
                Assert.AreEqual(dt.Month, ((DateTime)model.DateTimeField).Month);
                Assert.AreEqual(dt.Day, ((DateTime)model.DateTimeField).Day);
                Assert.AreEqual(dt.Hour, ((DateTime)model.DateTimeField).Hour);
                Assert.AreEqual(dt.Minute, ((DateTime)model.DateTimeField).Minute);
                Assert.AreEqual(dt.Second, ((DateTime)model.DateTimeField).Second);

                model.DateTimeField = dt + new TimeSpan(1, 1, 1);
                proxy.SetEntry(model);

                Assert.AreEqual(dt.Year, ((DateTime)model.DateTimeField).Year);
                Assert.AreEqual(dt.Month, ((DateTime)model.DateTimeField).Month);
                Assert.AreEqual(dt.Day, ((DateTime)model.DateTimeField).Day);
                Assert.AreEqual(dt.Hour + 1, ((DateTime)model.DateTimeField).Hour);
                Assert.AreEqual(dt.Minute + 1, ((DateTime)model.DateTimeField).Minute);
                //the second may error in some case
                Assert.AreEqual(dt.Second + 1, ((DateTime)model.DateTimeField).Second);

                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
示例#10
0
        public void ARProxy_DeleteEntry_By_EntryId()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                }
                );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);

                //delete
                proxy.DeleteEntry(entryId);
                NRemedy_Test_Regular_Form model2 = proxy.GetEntry(entryId);
                Assert.IsNull(model2);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
示例#11
0
 public void ARProxy_CreateEntry_simple_success()
 {
     ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
     try
     {
         //create a generic type proxy to perform API
         ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
         //simply use a model instance to create an entry
         string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form {
             CharacterField = TestCharacterFieldValue
         });
         Assert.AreNotEqual(null, entryId);
         //also use a entryid(request id) to get entry from AR
         NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
         Assert.AreEqual(TestCharacterFieldValue, model.CharacterField);
     }
     catch (Exception ex)
     {
         Assert.AreEqual(null, ex);
     }
     finally
     {
         context.Dispose();
     }
 }
示例#12
0
        public void ARProxy_CreateEntry_from_delegation()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                },
                //define a delegate only save status
                delegate(System.Reflection.PropertyInfo pi)
                {
                    return pi.Name == "Status";
                }
                );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                Assert.AreEqual(null, null);//
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
示例#13
0
        public void ARProxy_CreateEntry_datatype_Real()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    RealNumberField = 3.14
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(3.14, model.RealNumberField);

                model.RealNumberField = 0.62;
                proxy.SetEntry(model);

                Assert.AreEqual(0.62, model.RealNumberField);

                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
示例#14
0
        public void ARProxy_CreateEntry_datatype_int()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    IntegerField = 256
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(256, model.IntegerField);

                model.IntegerField = 512;
                proxy.SetEntry(model);

                Assert.AreEqual(512, model.IntegerField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
示例#15
0
        public void ARProxy_CreateEntry_datatype_Enum_NULL()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    Radio_Button_Field = null//
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                Assert.AreEqual(null, model.RealNumberField);//

                model.Status = NRemedy_Test_Regular_Form.Status_Enum.Rejected;
                model.Radio_Button_Field = NRemedy_Test_Regular_Form.Radio_Button_Field_Enum.First;//
                proxy.SetEntry(model);

                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Rejected, model.Status);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Radio_Button_Field_Enum.First, model.Radio_Button_Field);//
                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
示例#16
0
 public void Login_with_chinese_admin_success()
 {
     ARLoginContext context = null;
     try
     {
         context = new ARLoginContext(TestServer, TestChineseUser, TestChineseUserPwd);
     }
     catch (ARException ex)
     {
         Assert.AreEqual(null, ex);
     }
     finally
     {
         if(context != null)
             context.Dispose();
     }
 }
示例#17
0
 public void Login_with_admin_failed_and_try_a_success_again()
 {
     ARLoginContext context = null;
     try
     {
         context = new ARLoginContext(TestServer, TestChineseUser, TestChineseUserPwd + "something");
     }
     catch (ARException ex)
     {
         Assert.AreEqual(623, ex.MessageNumber); //183977-ErrorMsgs-7604.pdf page  72
         try
         {
             context = new ARLoginContext(TestServer, TestChineseUser, TestChineseUserPwd);
         }
         catch
         {
             Assert.AreEqual(null, ex);
         }
     }
     finally
     {
         if(context != null)
             context.Dispose();
     }
 }
示例#18
0
        public void ARProxy_GetEntry_By_Properties_Ids()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.14m,
                    IntegerField = 10
                }
                );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId, new List<uint>{
                    7u,
                    TestDecimalFieldId
                });

                Assert.IsNull(model.CharacterField);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                Assert.AreEqual(3.14m, model.DecimalNumberField);
                Assert.AreEqual(null, model.IntegerField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }