Ejemplo n.º 1
0
        public void TestPersistenceServiceFindById_Dictionary()
        {
            List <Dictionary <String, Object> > listPerson = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         person     = new Dictionary <String, Object>();

            person["age"]  = 15;
            person["name"] = "Alexandra";

            List <String> listId = new List <String>();

            listPerson.Add(person);
            listId = (List <String>)Backendless.Data.Of("Person").Create(listPerson);

            person["objectId"] = listId[0];
            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("age");
            Dictionary <String, Object> result = Backendless.Data.Of("Person").FindById(person, queryBuilder);

            Assert.IsNotNull(result);
            Assert.AreEqual(result["objectId"], listId[0], "Object id were not equivalent");
            Assert.IsFalse(result.ContainsKey("name"));
            Assert.IsTrue(result.ContainsKey("age"));

            Backendless.Data.Of("Person").Remove("age = '15'");
        }
Ejemplo n.º 2
0
        public void TestPersistenceServiceFindById_StringId_Async()
        {
            List <Dictionary <String, Object> > listPerson = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         person     = new Dictionary <String, Object>();

            person["age"]  = 15;
            person["name"] = "Alexandra";

            List <String> listId = new List <String>();

            listPerson.Add(person);
            listId = (List <String>)Backendless.Data.Of("Person").Create(listPerson);

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("age");
            Backendless.Data.Of("Person").FindById(listId[0], queryBuilder, new AsyncCallback <Dictionary <String, Object> >(
                                                       callback =>
            {
                Assert.IsNotNull(callback);
                Assert.AreEqual(callback["objectId"], listId[0], "Object id were not equivalent");
                Assert.IsFalse(callback.ContainsKey("name"));
                Assert.IsTrue(callback.ContainsKey("age"));
            },
                                                       fault =>
            {
                throw new ArgumentException("Error");
            }));

            Backendless.Data.Of("Person").Remove("age = '15'");
        }
Ejemplo n.º 3
0
        public void TestRelatedField()
        {
            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("*", "Location.adress");

            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Person").Find(queryBuilder);

            Assert.IsTrue(res[0].ContainsKey("adress"), "First object does not contain 'adress' field");
            Assert.IsTrue(res[1].ContainsKey("adress"), "Second object does not contain 'adress' field");
        }
Ejemplo n.º 4
0
        public void TestCreateFieldTIME()
        {
            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("*", "TIME(created) as myTime");

            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Person").Find(queryBuilder);

            Assert.IsTrue(res[0].ContainsKey("myTime"), "First object does not contain 'myTime' key");
            Assert.IsTrue(res[1].ContainsKey("myTime"), "Second object does not contain 'myTime' key");
        }
Ejemplo n.º 5
0
        public void TestExcludeTwoFields()
        {
            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("*");
            queryBuilder.ExcludeProperties("name", "age");

            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Person").Find(queryBuilder);

            Assert.IsFalse(res[0].ContainsKey("name"), "First object is contains key 'name'");
            Assert.IsFalse(res[0].ContainsKey("age"), "First object is contains key 'age'");

            Assert.IsFalse(res[1].ContainsKey("name"), "First object is contains key 'name'");
            Assert.IsFalse(res[1].ContainsKey("age"), "First object is contains key 'age'");
        }
Ejemplo n.º 6
0
        public void JN4()
        {
            Dictionary <String, Object> map = CreateDefaultJson();

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("json->'$.timeMarks.time' as time");
            var newMap = Backendless.Data.Of("Table1").Find(queryBuilder)[0];

            Assert.IsTrue(newMap != null && newMap != new Dictionary <String, Object>());
            Assert.IsTrue(newMap.Keys.Count == 3);
            Assert.IsTrue(newMap.Keys.Contains("objectId"));
            Assert.IsTrue(newMap.Keys.Contains("___class"));
            Assert.IsTrue(newMap.Keys.Contains("time"));
            Assert.IsTrue(newMap["time"] != null);

            Backendless.Data.Of("Table1").Remove(newMap);
        }