public void Test_0002_Subscribe_Bucket()
        {
            this.LogIn();
            ClearClientRequest();
            client.AddResponse(200, null);
            KiiBucket bucket = KiiUser.CurrentUser.Bucket("my_bucket");

            KiiUser.CurrentUser.PushSubscription.Subscribe(bucket);
            Assert.AreEqual(KiiHttpMethod.PUT, client.RequestMethod [0]);
            Assert.AreEqual("https://api.kii.com/api/apps/appId/users/user1234/buckets/my_bucket/filters/all/push/subscriptions/users/user1234", client.RequestUrl [0]);
        }
        public void Test_0010_Unsubscribe_Bucket_Async()
        {
            this.LogIn();
            ClearClientRequest();
            client.AddResponse(200, null);
            KiiBucket bucket = KiiUser.CurrentUser.Bucket("my_bucket");

            KiiUser.CurrentUser.PushSubscription.Unsubscribe(bucket, (KiiSubscribable target, Exception e) => {
                Assert.AreEqual(KiiHttpMethod.DELETE, client.RequestMethod [0]);
                Assert.AreEqual("https://api.kii.com/api/apps/appId/users/user1234/buckets/my_bucket/filters/all/push/subscriptions/users/user1234", client.RequestUrl [0]);
            });
        }
        public void Test_0016_IsSubscribed_Bucket_false()
        {
            this.LogIn();
            ClearClientRequest();
            client.AddResponse(404, null);
            KiiBucket bucket       = KiiUser.CurrentUser.Bucket("my_bucket");
            bool      isSubscribed = KiiUser.CurrentUser.PushSubscription.IsSubscribed(bucket);

            Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]);
            Assert.AreEqual("https://api.kii.com/api/apps/appId/users/user1234/buckets/my_bucket/filters/all/push/subscriptions/users/user1234", client.RequestUrl [0]);
            Assert.IsFalse(isSubscribed);
        }
Exemple #4
0
        public void Test_0000_ListAclEntries()
        {
            LogIn("test-user-00001");
            // set response
            this.SetStandardGetResponse(client);

            KiiBucket bucket = Kii.Bucket("test");
            IList <KiiACLEntry <KiiBucket, BucketAction> > list = bucket.ListAclEntries();

            // Assertion
            Assert.AreEqual(2, list.Count);
        }
        public void Test_0004_GeoDistanceQuery_sort_asc()
        {
            KiiBucket   bucket = testUser.Bucket("aBucket");
            KiiObject   obj1   = bucket.NewKiiObject();
            KiiGeoPoint point1 = new KiiGeoPoint(35.672568, 139.723606);

            obj1.SetGeoPoint("myLoc", point1);
            obj1.Save();

            KiiObject   obj2   = bucket.NewKiiObject();
            KiiGeoPoint point2 = new KiiGeoPoint(35.667983, 139.739356);

            obj2.SetGeoPoint("myLoc", point2);
            obj2.Save();
            // not in radius
            KiiObject   obj3   = bucket.NewKiiObject();
            KiiGeoPoint point3 = new KiiGeoPoint();

            obj3.SetGeoPoint("myLoc", point3);
            obj3.Save();

            KiiGeoPoint center = new KiiGeoPoint(35.677379, 139.702148);
            KiiClause   clause = KiiClause.GeoDistance("myloc", center, 4000, "distanceToMyLoc");
            KiiQuery    query  = new KiiQuery(clause);

            query.SortByAsc("_calculated.distanceToMyLoc");

            KiiQueryResult <KiiObject> result = bucket.Query(query);

            Assert.AreEqual(result.Count, 2);
            KiiObject   retObj1   = result [0];
            KiiGeoPoint retPoint1 = retObj1.GetGeoPoint("myLoc");

            Assert.AreEqual(point1.Latitude, retPoint1.Latitude);
            Assert.AreEqual(point1.Longitude, retPoint1.Longitude);
            JsonObject jObj1 = retObj1.GetJsonObject("_calculated");

            KiiObject   retObj2   = result [1];
            KiiGeoPoint retPoint2 = retObj2.GetGeoPoint("myLoc");

            Assert.AreEqual(point2.Latitude, retPoint2.Latitude);
            Assert.AreEqual(point2.Longitude, retPoint2.Longitude);
            JsonObject jObj2 = retObj2.GetJsonObject("_calculated");

            double retDistance1      = jObj1.GetDouble("distanceToMyLoc");
            double retDistance2      = jObj2.GetDouble("distanceToMyLoc");
            double expectedDistance1 = distanceInMeter(point1, center);
            double expectedDistance2 = distanceInMeter(point2, center);

            Assert.IsTrue(approximateEqual(expectedDistance1, retDistance1, 0.00001));
            Assert.IsTrue(approximateEqual(expectedDistance2, retDistance2, 0.00001));
        }
        public void Test_1_4_CountWhenBucketParentNotExists()
        {
            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;

            // set response
            MockHttpClient client           = factory.Client;
            string         mockResponseBody = "{\"errorCode\" : \"USER_NOT_FOUND\"}";

            client.AddResponse(new CloudException(404, mockResponseBody));

            string         bucketName = "TestBucket";
            KiiUser        user       = KiiUser.CreateByUri(new Uri("kiicloud://users/dummyUserId"));
            KiiBucket      bucket     = user.Bucket(bucketName);
            CloudException exp        = null;

            try {
                bucket.Count();
                Assert.Fail("Exception not thrown");
            } catch (CloudException e) {
                exp = e;
            }
            Assert.IsNotNull(exp);
            Assert.AreEqual(404, exp.Status);
            Assert.AreEqual(mockResponseBody, exp.Body);

            // check request.
            string url = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "users", "dummyUserId", "buckets", "TestBucket", "query");

            Assert.AreEqual(url, client.RequestUrl[0]);
            Assert.AreEqual(KiiHttpMethod.POST, client.RequestMethod[0]);
            MockHttpHeaderList headerList = client.RequestHeader[0];

            Assert.AreEqual("appId", headerList["X-Kii-AppID"]);
            Assert.AreEqual("appKey", headerList["X-Kii-AppKey"]);
            string queryStr = "{ " +
                              "\"bucketQuery\" : {" +
                              "\"clause\" : {" +
                              "\"type\" : \"all\"" +
                              "}," +
                              "\"aggregations\" : [ {" +
                              "\"type\" : \"COUNT\"," +
                              "\"putAggregationInto\" : \"count_field\"" +
                              "}]" +
                              "}" +
                              "}";
            JsonObject expectedBodyJson = new JsonObject(queryStr);
            JsonObject actualBodyJson   = new JsonObject(client.RequestBody[0]);

            KiiAssertion.AssertJson(expectedBodyJson, actualBodyJson);
        }
        public void Test_0019_IsSubscribed_Bucket_Async_true()
        {
            this.LogIn();
            ClearClientRequest();
            client.AddResponse(204, null);
            KiiBucket bucket = KiiUser.CurrentUser.Bucket("my_bucket");

            KiiUser.CurrentUser.PushSubscription.IsSubscribed(bucket, (KiiSubscribable target, bool isSubscribed, Exception e) => {
                Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]);
                Assert.AreEqual("https://api.kii.com/api/apps/appId/users/user1234/buckets/my_bucket/filters/all/push/subscriptions/users/user1234", client.RequestUrl [0]);
                Assert.IsTrue(isSubscribed);
            });
        }
        public void Test_0103_query_broken_json()
        {
            Kii.Initialize("appId", "appKey", Kii.Site.US);
            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;

            // set response
            MockHttpClient client = (MockHttpClient)factory.Client;

            client.AddResponse(200, "{}");

            KiiBucket bucket = Kii.Bucket("test");

            bucket.Query(null);
        }
        public void Test_0201_delete_server_exception()
        {
            Kii.Initialize("appId", "appKey", Kii.Site.US);
            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;

            // set response
            MockHttpClient client = (MockHttpClient)factory.Client;

            client.AddResponse(new CloudException(400, "{}"));

            KiiBucket bucket = Kii.Bucket("test");

            bucket.Delete();
        }
        public void Test_1_3_CountWhenObjectExistsInBucket()
        {
            string    bucketName = "bucket" + CurrentTimeMillis();
            KiiBucket bucket     = Kii.Bucket(bucketName);

            for (int i = 0; i < 10; i++)
            {
                KiiObject obj = bucket.NewKiiObject();
                obj ["intField"] = i;
                obj.Save();
            }

            int count = bucket.Count();

            Assert.AreEqual(10, count);
        }
        public void Test_0200_delete()
        {
            Kii.Initialize("appId", "appKey", Kii.Site.US);
            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;

            // set response
            MockHttpClient client = (MockHttpClient)factory.Client;

            this.SetDefaultDeleteResult(client);

            KiiBucket bucket = Kii.Bucket("test");

            bucket.Delete();
        }
        public void Test_1003_ListAclEntries_unknown_action()
        {
            LogIn("test-user-00001");
            // set response
            client.AddResponse(200, "{" +
                               "\"QUERY_OBJECTS_IN_BUCKET\":[" +
                               "{\"userID\":\"user1234\"}" +
                               "]," +
                               "\"READ_EXISTING_OBJECT\":[" +
                               "{\"userID\":\"user5678\"}" +
                               "]," +
                               "\"DROP_BUCKET_WITH_ALL_CONTENT\":[" +
                               "{\"groupID\":\"group5678\"}" +
                               "]" +
                               "}"
                               );

            KiiBucket bucket = Kii.Bucket("test");

            // list
            IList <KiiACLEntry <KiiBucket, BucketAction> > entries = null;
            Exception exception = null;

            bucket.ListAclEntries((IList <KiiACLEntry <KiiBucket, BucketAction> > list, Exception e) =>
            {
                entries   = list;
                exception = e;
            });
            // Assertion
            Assert.IsNotNull(entries);
            Assert.IsNull(exception);

            Assert.AreEqual(2, entries.Count);

            // entry 1
            KiiACLEntry <KiiBucket, BucketAction> entry = entries[0];

            Assert.AreEqual(BucketAction.DROP_BUCKET_WITH_ALL_CONTENT, entry.Action);
            Assert.IsTrue(entry.Subject is KiiGroup);
            Assert.AreEqual("kiicloud://groups/group5678", ((KiiGroup)entry.Subject).Uri.ToString());

            // entry 2
            entry = entries[1];
            Assert.AreEqual(BucketAction.QUERY_OBJECTS_IN_BUCKET, entry.Action);
            Assert.IsTrue(entry.Subject is KiiUser);
            Assert.AreEqual("kiicloud://users/user1234", ((KiiUser)entry.Subject).Uri.ToString());
        }
        public void Test_2_3_CountWithEqQueryWhenObjectExists()
        {
            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;

            // set response
            MockHttpClient client = factory.Client;

            client.AddResponse(200, "{\"aggregations\" : { \"count_field\" : 10 } }");

            string    bucketName = "TestBucket";
            KiiBucket bucket     = Kii.Bucket(bucketName);
            KiiClause clause     = KiiClause.Equals("key", "value");
            KiiQuery  query      = new KiiQuery(clause);
            int       count      = bucket.Count(query);

            Assert.AreEqual(10, count);

            // check request.
            Console.WriteLine(client.RequestBody[0]);
            string url = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "buckets", "TestBucket", "query");

            Assert.AreEqual(url, client.RequestUrl[0]);
            Assert.AreEqual(KiiHttpMethod.POST, client.RequestMethod[0]);
            MockHttpHeaderList headerList = client.RequestHeader[0];

            Assert.AreEqual("appId", headerList["X-Kii-AppID"]);
            Assert.AreEqual("appKey", headerList["X-Kii-AppKey"]);
            String queryStr = "{ " +
                              "\"bucketQuery\" : {" +
                              "\"clause\" : {" +
                              "\"type\" : \"eq\"," +
                              "\"field\" : \"key\"," +
                              "\"value\" : \"value\"" +
                              "}," +
                              "\"aggregations\" : [ {" +
                              "\"type\" : \"COUNT\"," +
                              "\"putAggregationInto\" : \"count_field\"" +
                              "}]" +
                              "}" +
                              "}";
            JsonObject expectedBodyJson = new JsonObject(queryStr);
            JsonObject actualBodyJson   = new JsonObject(client.RequestBody[0]);

            KiiAssertion.AssertJson(expectedBodyJson, actualBodyJson);
        }
        public void Test_0102_query_next()
        {
            // set response
            client.AddResponse(200, "{" +
                               "\"queryDescription\" : \"WHERE ( 1 = 1 )\"," +
                               "\"results\":[" +
                               "{\"_id\":\"497fd6ff-9178-42ec-b6ec-14bce7b5c7c9\",\"name\":\"Nick\",\"age\":18," +
                               "\"_created\":1334505527480,\"_modified\":1334505527480,\"_owner\":\"789399f7-7552-47a8-a524-b9119056edd9\",\"_version\":1}" +
                               "]," +
                               "\"nextPaginationKey\":\"abcd\"" +
                               "}");

            KiiBucket bucket = Kii.Bucket("test");
            KiiQuery  query  = new KiiQuery();

            bool done        = false;
            int  calledCount = 0;
            KiiQueryCallback <KiiObject> callback = null;

            callback = (KiiQueryResult <KiiObject> result, Exception e) =>
            {
                ++calledCount;
                if (calledCount == 1)
                {
                    // first result
                    Assert.AreEqual(1, result.Count);
                    Assert.IsTrue(result.HasNext);
                    Assert.AreEqual("Nick", result[0]["name"]);

                    // set response
                    this.SetDefaultQueryResult();
                    result.GetNextQueryResult(callback);
                }
                else
                {
                    Assert.AreEqual(1, result.Count);
                    Assert.IsFalse(result.HasNext);
                    Assert.AreEqual("John Smith", result[0]["name"]);

                    done = true;
                }
            };
            bucket.Query(query, callback);

            Assert.IsTrue(done);
        }
        public void Test_2_5_CountWithQuery()
        {
            string    bucketName = "bucket" + CurrentTimeMillis();
            KiiBucket bucket     = Kii.Bucket(bucketName);

            for (int i = 0; i < 15; i++)
            {
                KiiObject obj = bucket.NewKiiObject();
                obj ["intField"] = i;
                obj.Save();
            }

            KiiClause clause = KiiClause.GreaterThanOrEqual("intField", 10);
            int       count  = bucket.Count(new KiiQuery(clause));

            Assert.AreEqual(5, count);
        }
        public void Test_0100_query_null()
        {
            Kii.Initialize("appId", "appKey", Kii.Site.US);
            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;

            // set response
            MockHttpClient client = (MockHttpClient)factory.Client;

            this.SetDefaultQueryResult(client);

            KiiBucket bucket = Kii.Bucket("test");
            KiiQueryResult <KiiObject> result = bucket.Query(null);

            Assert.AreEqual(1, result.Count);
        }
        public void Test_0200_delete()
        {
            // set response
            this.SetDefaultDeleteResult();

            KiiBucket bucket    = Kii.Bucket("test");
            bool      done      = false;
            KiiBucket result    = null;
            Exception exception = null;

            bucket.Delete((KiiBucket deletedBucket, Exception e) =>
            {
                done      = true;
                result    = deletedBucket;
                exception = e;
            });
            Assert.IsTrue(done);
            Assert.IsNotNull(result);
            Assert.IsNull(exception);
        }
        public void Test_1000_ListAclEntries()
        {
            LogIn("test-user-00001");
            // set response
            this.SetStandardGetResponse(client);

            KiiBucket bucket = Kii.Bucket("test");
            IList <KiiACLEntry <KiiBucket, BucketAction> > list = null;
            Exception exception = null;

            bucket.ListAclEntries((IList <KiiACLEntry <KiiBucket, BucketAction> > entries, Exception e) =>
            {
                list      = entries;
                exception = e;
            });
            // Assertion
            Assert.IsNotNull(list);
            Assert.IsNull(exception);
            Assert.AreEqual(2, list.Count);
        }
        public void KiiBucketAclTest()
        {
            KiiBucket appBukcetA  = Kii.Bucket("AA");
            KiiBucket appBukcetA_ = Kii.Bucket("AA");
            KiiBucket appBukcetB  = Kii.Bucket("BB");
            KiiBucket usrBucketA  = KiiUser.CreateByUri(new Uri("kiicloud://users/user1234")).Bucket("AA");

            KiiBucketAcl acl1 = null;
            KiiBucketAcl acl2 = null;

            // same app bucket
            acl1 = new KiiBucketAcl(appBukcetA);
            acl2 = new KiiBucketAcl(appBukcetA_);
            Assert.IsTrue(acl1.Equals(acl2));
            Assert.IsTrue(acl1.GetHashCode() == acl2.GetHashCode());
            Assert.IsFalse(acl1 == acl2);
            // same app bucket and same action
            acl1 = new KiiBucketAcl(appBukcetA, BucketAction.QUERY_OBJECTS_IN_BUCKET);
            acl2 = new KiiBucketAcl(appBukcetA_, BucketAction.QUERY_OBJECTS_IN_BUCKET);
            Assert.IsTrue(acl1.Equals(acl2));
            Assert.IsTrue(acl1.GetHashCode() == acl2.GetHashCode());
            Assert.IsFalse(acl1 == acl2);
            // different action
            acl1 = new KiiBucketAcl(appBukcetA, BucketAction.DROP_BUCKET_WITH_ALL_CONTENT);
            acl2 = new KiiBucketAcl(appBukcetA_, BucketAction.QUERY_OBJECTS_IN_BUCKET);
            Assert.IsFalse(acl1.Equals(acl2));
            Assert.IsFalse(acl1.GetHashCode() == acl2.GetHashCode());
            Assert.IsFalse(acl1 == acl2);
            // different bucket name
            acl1 = new KiiBucketAcl(appBukcetA, BucketAction.QUERY_OBJECTS_IN_BUCKET);
            acl2 = new KiiBucketAcl(appBukcetB, BucketAction.QUERY_OBJECTS_IN_BUCKET);
            Assert.IsFalse(acl1.Equals(acl2));
            Assert.IsFalse(acl1.GetHashCode() == acl2.GetHashCode());
            Assert.IsFalse(acl1 == acl2);
            // different scope of bucket
            acl1 = new KiiBucketAcl(appBukcetA, BucketAction.QUERY_OBJECTS_IN_BUCKET);
            acl2 = new KiiBucketAcl(usrBucketA, BucketAction.QUERY_OBJECTS_IN_BUCKET);
            Assert.IsFalse(acl1.Equals(acl2));
            Assert.IsFalse(acl1.GetHashCode() == acl2.GetHashCode());
            Assert.IsFalse(acl1 == acl2);
        }
        public void Test_0104_query_server_error()
        {
            // set response
            client.AddResponse(new CloudException(400, "{}"));

            KiiBucket bucket = Kii.Bucket("test");
            bool      done   = false;
            KiiQueryResult <KiiObject> result = null;
            Exception exception = null;

            bucket.Query(null, (KiiQueryResult <KiiObject> list, Exception e) =>
            {
                done      = true;
                result    = list;
                exception = e;
            });
            Assert.IsTrue(done);
            Assert.IsNull(result);
            Assert.IsNotNull(exception);
            Assert.IsTrue(exception is CloudException);
        }
        public void Test_0201_delete_server_exception()
        {
            // set response
            client.AddResponse(new CloudException(400, "{}"));

            KiiBucket bucket    = Kii.Bucket("test");
            bool      done      = false;
            KiiBucket result    = null;
            Exception exception = null;

            bucket.Delete((KiiBucket deletedBucket, Exception e) =>
            {
                done      = true;
                result    = deletedBucket;
                exception = e;
            });
            Assert.IsTrue(done);
            Assert.IsNotNull(result);
            Assert.IsNotNull(exception);
            Assert.IsTrue(exception is CloudException);
        }
        public void Test_0103_query_broken_json()
        {
            // set response
            client.AddResponse(200, "{}");

            KiiBucket bucket = Kii.Bucket("test");
            bool      done   = false;
            KiiQueryResult <KiiObject> result = null;
            Exception exception = null;

            bucket.Query(null, (KiiQueryResult <KiiObject> list, Exception e) =>
            {
                done      = true;
                result    = list;
                exception = e;
            });
            Assert.IsTrue(done);
            Assert.IsNull(result);
            Assert.IsNotNull(exception);
            Assert.IsTrue(exception is IllegalKiiBaseObjectFormatException);
        }
Exemple #23
0
        public void Test_2_2_CountWithQueryWhenObjectExistsInBucket()
        {
            string    bucketName = "TestBucket" + CurrentTimeMillis();
            KiiBucket bucket     = Kii.Bucket(bucketName);

            for (int i = 0; i < 10; i++)
            {
                KiiObject obj = bucket.NewKiiObject();
                obj ["key"] = "value";
                obj.Save();
            }

            KiiBucket      callbackBucket = null;
            KiiQuery       callbackQuery  = null;
            int            count          = -1;
            Exception      exp            = null;
            CountDownLatch cd             = new CountDownLatch(1);

            KiiClause clause = KiiClause.Equals("key", "value");
            KiiQuery  query  = new KiiQuery(clause);

            bucket.Count(query, (KiiBucket b, KiiQuery q, int c, Exception e) => {
                callbackBucket = b;
                callbackQuery  = q;
                count          = c;
                exp            = e;
                cd.Signal();
            });

            if (!cd.Wait(new TimeSpan(0, 0, 0, 3)))
            {
                Assert.Fail("Callback not fired.");
            }
            Assert.IsNotNull(callbackBucket);
            Assert.AreEqual(bucket.Uri, callbackBucket.Uri);
            Assert.IsNotNull(callbackQuery);
            Assert.AreEqual(query.ToString(), callbackQuery.ToString());
            Assert.IsNull(exp);
            Assert.AreEqual(10, count);
        }
        public void Test_1002_ListAclEntries_broken_json()
        {
            LogIn("test-user-00001");
            // set response
            client.AddResponse(200, "broken");

            KiiBucket bucket = Kii.Bucket("test");

            // list
            IList <KiiACLEntry <KiiBucket, BucketAction> > list = null;
            Exception exception = null;

            bucket.ListAclEntries((IList <KiiACLEntry <KiiBucket, BucketAction> > entries, Exception e) =>
            {
                list      = entries;
                exception = e;
            });
            // Assertion
            Assert.IsNull(list);
            Assert.IsNotNull(exception);
            Assert.IsTrue(exception is IllegalKiiBaseObjectFormatException);
        }
Exemple #25
0
        public void Test_0200_Bucket()
        {
            Kii.Initialize("ee573743", "5eb7b8bc1b4e4c98e659431c69cef8d4", Kii.Site.US);
            KiiBucket bucket = Kii.Bucket("appBucket");

            Assert.AreEqual("kiicloud://buckets/appBucket", bucket.Uri.ToString());

            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;

            // set response
            MockHttpClient client = factory.Client;

            this.SetStandardSaveResponse(client);

            KiiObject obj = bucket.NewKiiObject();

            obj.Save();

            Assert.AreEqual("kiicloud://buckets/appBucket/objects/d8dc9f29-0fb9-48be-a80c-ec60fddedb54", obj.Uri.ToString());
        }
        public void Test_1001_ListAclEntries_server_error()
        {
            LogIn("test-user-00001");
            // set response
            client.AddResponse(new CloudException(400, "{}"));

            KiiBucket bucket = Kii.Bucket("test");

            // list
            IList <KiiACLEntry <KiiBucket, BucketAction> > list = null;
            Exception exception = null;

            bucket.ListAclEntries((IList <KiiACLEntry <KiiBucket, BucketAction> > entries, Exception e) =>
            {
                list      = entries;
                exception = e;
            });
            // Assertion
            Assert.IsNull(list);
            Assert.IsNotNull(exception);
            Assert.IsTrue(exception is CloudException);
        }
        public void Test_0100_query_null()
        {
            // set response
            this.SetDefaultQueryResult();

            KiiBucket bucket = Kii.Bucket("test");
            bool      done   = false;
            KiiQueryResult <KiiObject> result = null;
            Exception exception = null;

            bucket.Query(null, (KiiQueryResult <KiiObject> list, Exception e) =>
            {
                done      = true;
                result    = list;
                exception = e;
            });
            Assert.IsTrue(done);
            Assert.IsNotNull(result);
            Assert.IsNull(exception);

            Assert.AreEqual(1, result.Count);
        }
        public void Test_0002_GeoDistanceQuery_calculatedDistance_nil()
        {
            KiiBucket   bucket = testUser.Bucket("aBucket");
            KiiObject   obj    = bucket.NewKiiObject();
            KiiGeoPoint point  = new KiiGeoPoint(35.667983, 139.739356);

            obj.SetGeoPoint("myLoc", point);
            obj.Save();

            KiiGeoPoint center = new KiiGeoPoint(35.677379, 139.702148);
            KiiClause   clause = KiiClause.GeoDistance("myloc", center, 4000, "");
            KiiQuery    query  = new KiiQuery(clause);
            KiiQueryResult <KiiObject> result = bucket.Query(query);
            KiiObject   retObj = result [0];
            KiiGeoPoint retPoint;

            retPoint = retObj.GetGeoPoint("myLoc");
            Assert.AreEqual(point.Latitude, retPoint.Latitude);
            Assert.AreEqual(point.Longitude, retPoint.Longitude);

            Assert.IsFalse(retObj.Has("_calculated"));
        }
        public void NotAndTest()
        {
            KiiBucket bucket = KiiUser.CurrentUser.Bucket("my_bucket");
            KiiObject obj1   = bucket.NewKiiObject();

            obj1["name"] = "foo";
            obj1["age"]  = 20;
            obj1.Save();
            KiiObject obj2 = bucket.NewKiiObject();

            obj2["name"] = "foo";
            obj2["age"]  = 33;
            obj2.Save();

            KiiQuery query = new KiiQuery(KiiClause.Not(KiiClause.And(KiiClause.Equals("name", "foo"), KiiClause.LessThan("age", 30))));

            query.SortByAsc("name");

            KiiQueryResult <KiiObject> results = bucket.Query(query);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(33, results[0].GetInt("age"));
        }
        public void NotGeoBoxTest()
        {
            KiiBucket bucket = KiiUser.CurrentUser.Bucket("my_bucket");
            KiiObject obj1   = bucket.NewKiiObject();

            obj1["name"] = "kii";
            obj1.SetGeoPoint("location", new KiiGeoPoint(35.668387, 139.739495));
            obj1.Save();
            KiiObject obj2 = bucket.NewKiiObject();

            obj2["name"] = "TDL";
            obj2.SetGeoPoint("location", new KiiGeoPoint(35.633114, 139.880405));
            obj2.Save();

            KiiQuery query = new KiiQuery(KiiClause.Not(KiiClause.GeoBox("location", new KiiGeoPoint(35.669494, 139.741727), new KiiGeoPoint(35.660934, 139.734957))));

            query.SortByAsc("name");

            KiiQueryResult <KiiObject> results = bucket.Query(query);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("TDL", results[0].GetString("name"));
        }