Example #1
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();
            }
        }
Example #2
0
        public void LinqParse_select_oneproperty_clause()
        {
            using (ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd))
            {
                ARSet<NRemedy_Test_Regular_Form> set = new ARSet<NRemedy_Test_Regular_Form>(context);
                var q = from s in set
                        select s.CharacterField;
                Assert.IsTrue(q.Provider is ARQueryProvider<NRemedy_Test_Regular_Form>);
                TranslateResult tr = q.Translate<NRemedy_Test_Regular_Form>();
                Assert.IsTrue(tr.SelectResult != null);

                NRemedy_Test_Regular_Form tmp = new NRemedy_Test_Regular_Form();
                tmp.CharacterField = "tmp";

                var fun = tr.SelectResult.SelectExpression.Compile();
                Assert.AreEqual("tmp", (string)fun.DynamicInvoke(tmp));
                Assert.IsTrue(tr.SelectResult.SelectedProperties.First(m => m == "CharacterField") != null);
            }
        }
Example #3
0
        public void LinqParse_select_anouymous_object_clause()
        {
            using (ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd))
            {
                ARSet<NRemedy_Test_Regular_Form> set = new ARSet<NRemedy_Test_Regular_Form>(context);
                var q = from s in set
                        select new
                        {
                            s.RealNumberField,
                            s.DateTimeField
                        };
                Assert.IsTrue(q.Provider is ARQueryProvider<NRemedy_Test_Regular_Form>);
                TranslateResult tr = q.Translate<NRemedy_Test_Regular_Form>();
                Assert.IsTrue(tr.SelectResult != null);

                DateTime dt = DateTime.Now;
                NRemedy_Test_Regular_Form tmp = new NRemedy_Test_Regular_Form();
                tmp.RealNumberField = 3.14;
                tmp.DateTimeField = dt;

                var fun = tr.SelectResult.SelectExpression.Compile();
                dynamic dymic = fun.DynamicInvoke(tmp);
                Assert.AreEqual(3.14, dymic.RealNumberField);
                Assert.AreEqual(dt, dymic.DateTimeField);

                Assert.IsTrue(tr.SelectResult.SelectedProperties.First(m => m == "RealNumberField") != null);
                Assert.IsTrue(tr.SelectResult.SelectedProperties.First(m => m == "DateTimeField") != null);
            }
        }
Example #4
0
        public void LinqParse_select_another_object_clause()
        {
            using (ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd))
            {
                ARSet<NRemedy_Test_Regular_Form> set = new ARSet<NRemedy_Test_Regular_Form>(context);
                var q = from s in set
                        select new Temp
                        {
                            Str = s.CharacterField,
                            dt = (DateTime)s.DateTimeField,
                            de = (Decimal)s.DecimalNumberField
                        };
                Assert.IsTrue(q.Provider is ARQueryProvider<NRemedy_Test_Regular_Form>);
                //var tr2 = ((ARQueryProvider<NRemedy_Test_Regular_Form>)q.Provider).ExecuteOnlyTranslate(q.Expression);
                TranslateResult tr = q.Translate<NRemedy_Test_Regular_Form>();
                Assert.IsTrue(tr.SelectResult != null);

                DateTime dt = DateTime.Now;
                NRemedy_Test_Regular_Form tmp = new NRemedy_Test_Regular_Form();
                tmp.CharacterField = "3.14";
                tmp.DateTimeField = dt;
                tmp.DecimalNumberField = 3.14m;

                var fun = tr.SelectResult.SelectExpression.Compile();
                Temp temp = (Temp)fun.DynamicInvoke(tmp);
                Assert.AreEqual("3.14", temp.Str);
                Assert.AreEqual(dt, temp.dt);
                Assert.AreEqual(3.14m, temp.de);

                Assert.IsTrue(tr.SelectResult.SelectedProperties.First(m => m == "CharacterField") != null);
                Assert.IsTrue(tr.SelectResult.SelectedProperties.First(m => m == "DateTimeField") != null);
                Assert.IsTrue(tr.SelectResult.SelectedProperties.First(m => m == "DecimalNumberField") != null);
            }
        }