Ejemplo n.º 1
0
        public async Task Array()
        {
            // equal
            LCQuery <LCObject> query = new LCQuery <LCObject>("Book");

            query.WhereEqualTo("pages", 3);
            List <LCObject> results = await query.Find();

            results.ForEach(item => {
                List <object> pages = item["pages"] as List <object>;
                Assert.IsTrue(pages.Contains(3));
            });

            // contain all
            List <int> containAlls = new List <int> {
                1, 2, 3, 4, 5, 6, 7
            };

            query = new LCQuery <LCObject>("Book");
            query.WhereContainsAll("pages", containAlls);
            results = await query.Find();

            results.ForEach(item => {
                List <object> pages = item["pages"] as List <object>;
                pages.ForEach(i => {
                    Assert.IsTrue(pages.Contains(i));
                });
            });

            // contain in
            List <int> containIns = new List <int> {
                4, 5, 6
            };

            query = new LCQuery <LCObject>("Book");
            query.WhereContainedIn("pages", containIns);
            results = await query.Find();

            results.ForEach(item => {
                List <object> pages = item["pages"] as List <object>;
                bool f = false;
                containIns.ForEach(i => {
                    f |= pages.Contains(i);
                });
                Assert.IsTrue(f);
            });

            // size
            query = new LCQuery <LCObject>("Book");
            query.WhereSizeEqualTo("pages", 7);
            results = await query.Find();

            results.ForEach(item => {
                List <object> pages = item["pages"] as List <object>;
                Assert.AreEqual(pages.Count, 7);
            });
        }