예제 #1
0
        public void TestFetchOr()
        {
            Task.Run(async() =>
            {
                for (var i = 0; i < 5; i++)
                {
                    var item = new NCMBObject("QueryTest");
                    item.Set("message", "Test message");
                    item.Set("number", i);
                    await item.Save();
                }

                var q1 = new NCMBQuery("QueryTest");
                var q2 = new NCMBQuery("QueryTest");

                q1.EqualTo("number", 0);
                q2.EqualTo("number", 1);
                var query = new NCMBQuery("QueryTest");
                query.Or(new NCMBQuery[2] {
                    q1, q2
                });
                var items = await query.FetchAll();

                Assert.AreEqual(2, items.Length);
                var num0 = items[0].Get("number") as JValue;
                var num1 = items[1].Get("number") as JValue;

                Assert.AreEqual(0, num0.ToObject <int>());
                Assert.AreEqual(1, num1.ToObject <int>());
                query = new NCMBQuery("QueryTest");
                items = await query.FetchAll();
                foreach (var item in items)
                {
                    await item.Delete();
                }
            }).GetAwaiter().GetResult();
        }