예제 #1
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();
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
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();
            }
        }
예제 #4
0
        public static TModel GetEntry <TModel>(
            this ARProxy <TModel> proxy, string EntryId, params Expression <Func <TModel, object> >[] propertiesTobeUp)
            where TModel : ARBaseForm
        {
            if (propertiesTobeUp == null || propertiesTobeUp.Length == 0)
            {
                return(null);
            }
            ITypeMetaProvider <TModel> metaProvider = new ExpressionTypeMetaProvider <TModel>(propertiesTobeUp);

            ModelMeteData <TModel> MetaData = new ModelMeteData <TModel>();

            MetaData.FormName = metaProvider.GetFormNameFromModelType();
            MetaData.EntryId  = EntryId;

            var props = metaProvider.GetPropertyInfoes(BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance, null);

            MetaData.Properties = new List <PropertyAndField <TModel> >();

            foreach (var p in props)
            {
                if ((p.AccessLevel & ModelBinderAccessLevel.OnlyBind) == ModelBinderAccessLevel.OnlyBind)
                {
                    MetaData.Properties.Add(p);
                }
            }

            return(proxy.GetEntry(MetaData));
        }
예제 #5
0
        public void ARProxy_CreateEntry_datatype_Enum()
        {
            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);

                model.Status = NRemedy_Test_Regular_Form.Status_Enum.Rejected;
                proxy.SetEntry(model);

                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Rejected, model.Status);

                //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();
            }
        }
예제 #6
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();
            }
        }
예제 #7
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();
            }
        }
예제 #8
0
        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();
            }
        }
예제 #9
0
        public void ARProxy_CreateEntry_datatype_character_chinese_with_set()
        {
            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,
                    IntegerField   = 3
                });
                Assert.AreNotEqual(null, entryId);

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

                //SetEntry
                proxy.SetEntry(model);
                model = null;

                //GetAgain
                model = proxy.GetEntry(entryId);
                Assert.IsNotNull(model);
                Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", model.CharacterField);
                Assert.AreEqual(3, model.IntegerField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
예제 #10
0
        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();
            }
        }
예제 #11
0
        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();
            }
        }
예제 #12
0
        public void ARProxy_Create_Entry_with_Att_01()
        {
            using (ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd))
            {
                string testStr = "This is test string , which will be save as file and create entry into AR. The Test method is ARProxy_Create_Entry_with_Att_01";

                byte[] buff = Encoding.UTF8.GetBytes(testStr);

                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    Attachment = new ARAttachment {
                        AttchmentName = "ARProxy_Create_Entry_with_Att_01.txt",
                        Buff          = buff
                    }
                });


                NRemedy_Test_Regular_Form entry = proxy.GetEntry(entryId);

                entry.Attachment.AttchmentName = "ARProxy_Create_Entry_with_Att_01.txt";
                Assert.AreEqual(testStr, Encoding.UTF8.GetString(entry.Attachment.Buff));



                List <UInt32> attchFIds = new List <uint>();
                attchFIds.Add(attchFId);
                //int total = -1;
                IList <NRemedy_Test_Regular_Form> entries = proxy.GetEntryList(null, attchFIds, 0, null, null, null);
                foreach (var e in entries)
                {
                    if (e.Attachment != null && e.Attachment.AttchmentName == "ARProxy_Create_Entry_with_Att_01.txt")
                    {
                        Assert.AreEqual(testStr, Encoding.UTF8.GetString(e.Attachment.Buff));
                    }
                }
            }
        }
예제 #13
0
        public void ARProxy_Create_Entry_with_Att_01()
        {
            using (ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd))
            {

                string testStr = "This is test string , which will be save as file and create entry into AR. The Test method is ARProxy_Create_Entry_with_Att_01";

                byte[] buff = Encoding.UTF8.GetBytes(testStr);

                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    Attachment = new ARAttachment {
                        AttchmentName = "ARProxy_Create_Entry_with_Att_01.txt",
                        Buff = buff
                    }
                });

                NRemedy_Test_Regular_Form entry = proxy.GetEntry(entryId);

                entry.Attachment.AttchmentName = "ARProxy_Create_Entry_with_Att_01.txt";
                Assert.AreEqual(testStr, Encoding.UTF8.GetString(entry.Attachment.Buff));

                List<UInt32> attchFIds = new List<uint>();
                attchFIds.Add(attchFId);
                //int total = -1;
                IList<NRemedy_Test_Regular_Form> entries = proxy.GetEntryList(null, attchFIds, 0, null, null, null);
                foreach (var e in entries)
                {
                    if (e.Attachment != null && e.Attachment.AttchmentName == "ARProxy_Create_Entry_with_Att_01.txt")
                    {
                        Assert.AreEqual(testStr, Encoding.UTF8.GetString(e.Attachment.Buff));
                    }
                }

            }
        }
예제 #14
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();
            }
        }
        public void GetEntry_by_Expression_single_condition()
        {
            ARLoginContext context = null;
            try
            {
                context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
                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",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField = 10
                }
                );

                Assert.AreNotEqual(null, entryId);

                NRemedy_Test_Regular_Form entry = proxy.GetEntry(entryId,
                    m => m.CharacterField,
                    m => m.Status,
                    m => m.DecimalNumberField
                    );

                Assert.AreEqual("should not changed", entry.CharacterField);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, entry.Status);
                Assert.AreEqual(3.13m, entry.DecimalNumberField);
                Assert.AreEqual(null, entry.IntegerField);

            }
            finally {
                if (context != null)
                    context.Dispose();
            }
        }
        public void GetEntry_by_Expression_single_condition()
        {
            ARLoginContext context = null;
            try
            {
                context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
                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",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField = 10
                }
                );

                Assert.AreNotEqual(null, entryId);

                NRemedy_Test_Regular_Form entry = proxy.GetEntry(entryId,
                    m => m.CharacterField,
                    m => m.Status,
                    m => m.DecimalNumberField
                    );

                Assert.AreEqual("should not changed", entry.CharacterField);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, entry.Status);
                Assert.AreEqual(3.13m, entry.DecimalNumberField);
                Assert.AreEqual(null, entry.IntegerField);

            }
            finally {
                if (context != null)
                    context.Dispose();
            }
        }
예제 #17
0
        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();
            }
        }
예제 #18
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();
            }
        }
예제 #19
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();
            }
        }
예제 #20
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();
     }
 }
예제 #21
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();
            }
        }
예제 #22
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();
            }
        }
예제 #23
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();
            }
        }
예제 #24
0
        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();
            }
        }
예제 #25
0
        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();
            }
        }
예제 #26
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();
            }
        }