Esempio n. 1
0
        public void TestFetchPointerASync()
        {
            Task.Run(async() =>
            {
                var item1 = new NCMBObject("QueryTest");
                item1.Set("message", "Test message");
                item1.Set("number", 500);
                await item1.Save();

                var item2 = new NCMBObject("QueryTest");
                item2.Set("message", "Test message");
                item2.Set("number", 500);
                item2.Set("obj", item1);
                await item2.Save();

                var query = new NCMBQuery("QueryTest");
                query
                .EqualTo("objectId", item2.Get("objectId"))
                .Include("obj");
                var obj = await query.Fetch();
                Assert.AreEqual(obj.Get("objectId"), item2.Get("objectId"));
                Assert.AreEqual(((NCMBObject)obj.Get("obj")).Get("objectId"), item1.Get("objectId"));

                await obj.Delete();
                await item1.Delete();
            }).GetAwaiter().GetResult();
        }
Esempio n. 2
0
 public void TestSaveAndDeleteASync()
 {
     Task.Run(async() =>
     {
         var message = "Hello, world";
         var item    = new NCMBObject("DataStoreTest");
         item.Set("message", message);
         await item.Save();
         Assert.NotNull(item.Get("objectId"));
         Assert.AreEqual(item.Get("message").ToString(), message);
         await item.Delete();
     }).GetAwaiter().GetResult();
 }
Esempio n. 3
0
        public void TestRelationRemove()
        {
            Task.Run(async() =>
            {
                var item1 = new NCMBObject("RelationTest");
                await item1.Set("name", "item1").Save();
                var item2 = new NCMBObject("RelationTest");
                await item2.Set("name", "item2").Save();

                var relation = new NCMBRelation();
                relation.Add(item1).Add(item2);

                var item3 = new NCMBObject("RelationMaster");
                await item3.Set("relation", relation).Save();

                Assert.NotNull(item3.Get("objectId"));

                relation = new NCMBRelation();
                relation.Remove(item1);
                await item3.Set("relation", relation).Save();
                await item3.Delete();
                await item1.Delete();
                await item2.Delete();
            }).GetAwaiter().GetResult();
        }
Esempio n. 4
0
 public void TestSaveAndGetGeoPoint()
 {
     Task.Run(async() =>
     {
         var latitude  = 35.6585805;
         var longitude = 139.7454329;
         var geo       = new NCMBGeoPoint(latitude, longitude);
         var item      = new NCMBObject("Item");
         item.Set("geo", geo);
         await item.Save();
         await item.Fetch();
         var geo1 = (NCMBGeoPoint)item.Get("geo");
         Assert.NotNull(item.Get("objectId"));
         Assert.AreEqual(geo1.Latitude, geo.Latitude);
         await item.Delete();
     }).GetAwaiter().GetResult();
 }
Esempio n. 5
0
 public void TestSaveAndDeleteWithAclSync()
 {
     Task.Run(async() =>
     {
         var message = "Hello, world";
         var item    = new NCMBObject("DataStoreTest");
         item.Set("message", message);
         var acl = new NCMBAcl();
         acl.SetPublicReadAccess(true);
         acl.SetPublicWriteAccess(false);
         acl.SetRoleReadAccess("admin", true);
         acl.SetRoleWriteAccess("admin", true);
         item.SetAcl(acl);
         await item.Save();
         Assert.NotNull(item.Get("objectId"));
         Assert.AreEqual(item.Get("message").ToString(), message);
     }).GetAwaiter().GetResult();
 }
Esempio n. 6
0
        public void TestSetGeoPoint()
        {
            var latitude  = 35.6585805;
            var longitude = 139.7454329;
            var geo       = new NCMBGeoPoint(latitude, longitude);
            var item      = new NCMBObject("Item");

            item.Set("geo", geo);
            var geo1 = (NCMBGeoPoint)item.Get("geo");

            Assert.AreEqual(geo1.Latitude, geo.Latitude);
        }
Esempio n. 7
0
 public void TestSaveGetBoolean()
 {
     Task.Run(async() =>
     {
         var message = "Hello, world";
         var item    = new NCMBObject("DataStoreTest");
         item.Set("message", message);
         item.Set("bol1", true);
         item.Set("bol2", false);
         await item.Save();
         Assert.NotNull(item.Get("objectId"));
         await item.Fetch();
         Assert.IsTrue(item.GetBoolean("bol1"));
         Assert.IsTrue(!item.GetBoolean("bol2"));
         await item.Delete();
     }).GetAwaiter().GetResult();
 }
Esempio n. 8
0
        public void TestFetchInQuery()
        {
            Task.Run(async() =>
            {
                for (var i = 0; i < 5; i++)
                {
                    var item = new NCMBObject("Test");
                    item.Set("message", "Test message");
                    item.Set("number", i);
                    await item.Save();

                    var item2 = new NCMBObject("Test2");
                    item2.Set("message", "Test message");
                    item2.Set("num", item);
                    await item2.Save();
                }

                var q1 = new NCMBQuery("Test");
                var q2 = new NCMBQuery("Test2");

                q1.InString("number", new int[] { 1, 4 });
                var items = await q2.InQuery("num", q1).Include("num").FetchAll();
                Assert.IsTrue(items.Length > 0);
                foreach (var item in items)
                {
                    var num = ((NCMBObject)item.Get("num")).GetInt("number");
                    Assert.IsTrue(num == 4 || num == 1);
                }

                var query = new NCMBQuery("Test");
                items     = await query.FetchAll();
                foreach (var item in items)
                {
                    await item.Delete();
                }
                query = new NCMBQuery("Test2");
                items = await query.FetchAll();
                foreach (var item in items)
                {
                    await item.Delete();
                }
            }).GetAwaiter().GetResult();
        }
Esempio n. 9
0
        public void TestRelationFetch()
        {
            Task.Run(async() =>
            {
                var item1 = new NCMBObject("RelationTest");
                await item1.Set("name", "item1").Save();
                var item2 = new NCMBObject("RelationTest");
                await item2.Set("name", "item2").Save();

                var relation = new NCMBRelation();
                relation.Add(item1).Add(item2);

                var item3 = new NCMBObject("RelationMaster");
                await item3.Set("relation", relation).Save();
                Assert.NotNull(item3.Get("objectId"));

                var query = new NCMBQuery("RelationTest");
                var items = await query.RelatedTo(item3, "relation").FetchAll();

                Assert.AreEqual(items.Length, 2);
                Assert.AreEqual(items[0].Get("objectId").ToString(), item1.Get("objectId").ToString());
            }).GetAwaiter().GetResult();
        }