public void TestKVOperations()
        {
            const string key = "bucket_type_test_key";
            var id = new RiakObjectId(TestBucketType, TestBucket, key);
            var obj = new RiakObject(id, Value);

            // put
            var putResult = Client.Put(obj, new RiakPutOptions().SetReturnBody(true).SetDw(3));
            putResult.IsSuccess.ShouldBeTrue();
            putResult.Value.BucketType.ShouldEqual(TestBucketType);

            // get
            var getResult = Client.Get(id);
            getResult.IsSuccess.ShouldBeTrue();
            getResult.Value.BucketType.ShouldEqual(TestBucketType);

            // delete
            var deleteResult = Client.Delete(id, new RiakDeleteOptions().SetDw(3));
            deleteResult.IsSuccess.ShouldBeTrue();

            // multiget
            var ids = new List<RiakObjectId>();
            for (int i = 0; i < 3; i++)
            {
                obj = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key + i), Value);
                Client.Put(obj, new RiakPutOptions().SetReturnBody(true).SetDw(3));
                ids.Add(obj.ToRiakObjectId());
            }

            var multiGetResult = Client.Get(ids).ToList();
            multiGetResult.All(r => r.IsSuccess).ShouldBeTrue();
            multiGetResult.All(r => r.Value.BucketType == TestBucketType).ShouldBeTrue();
        }
        public void AsyncDeleteMultipleIsSuccessful()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List <RiakObjectId> {
                oneObjectId, twoObjectId
            };

            var results = Client.Async.Delete(list).Result;

            foreach (var riakResult in results)
            {
                riakResult.IsSuccess.ShouldBeTrue(riakResult.ErrorMessage);
            }

            var oneResult = Client.Get(oneObjectId);

            oneResult.IsSuccess.ShouldBeFalse();
            oneResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            oneResult.Value.ShouldBeNull();

            var twoResult = Client.Get(twoObjectId);

            twoResult.IsSuccess.ShouldBeFalse();
            twoResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            twoResult.Value.ShouldBeNull();
        }
        public void AsyncDeleteIsSuccessful()
        {
            var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);
            putResult.IsSuccess.ShouldBeTrue();

            RiakResult theResult = null;
            var resetEvent = new AutoResetEvent(false);

            Client.Async.Delete(riakObjectId, result =>
                                            {
                                                theResult = result;
                                                resetEvent.Set();
                                            });
            resetEvent.WaitOne();

            theResult.IsSuccess.ShouldBeTrue();

            var getResult = Client.Get(riakObjectId);
            getResult.IsSuccess.ShouldBeFalse();
            getResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            getResult.Value.ShouldBeNull();
        }
        public void AsyncDeleteIsSuccessful()
        {
            var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);

            putResult.IsSuccess.ShouldBeTrue();

            RiakResult theResult  = null;
            var        resetEvent = new AutoResetEvent(false);

            Client.Async.Delete(riakObjectId, result =>
            {
                theResult = result;
                resetEvent.Set();
            });
            resetEvent.WaitOne();

            theResult.IsSuccess.ShouldBeTrue();

            var getResult = Client.Get(riakObjectId);

            getResult.IsSuccess.ShouldBeFalse();
            getResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            getResult.Value.ShouldBeNull();
        }
        public void AsyncDeleteMultipleIsSuccessful()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one).ShouldNotBeNull();
            Client.Put(two).ShouldNotBeNull();

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List <RiakObjectId> {
                oneObjectId, twoObjectId
            };

            var deletedObjectIds = Client.Async.Delete(list)
                                   .ToEnumerable()
                                   .ToList();

            deletedObjectIds.Count().ShouldEqual(2);

            var oneResult = Client.Get(oneObjectId);

            oneResult.ShouldBeNull();

            var twoResult = Client.Get(twoObjectId);

            twoResult.ShouldBeNull();
        }
        public void AsyncGetMultipleReturnsAllObjects()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            IEnumerable <RiakResult <RiakObject> > theResults = null;

            var list = new List <RiakObjectId> {
                oneObjectId, twoObjectId
            };

            var resetEvent = new AutoResetEvent(false);

            Client.Async.Get(list, results =>
            {
                theResults = results;
                resetEvent.Set();
            });
            resetEvent.WaitOne();

            foreach (var result in theResults)
            {
                result.IsSuccess.ShouldBeTrue();
                result.Value.ShouldNotBeNull();
            }
        }
        public void AsyncDeleteMultipleIsSuccessful()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List<RiakObjectId> { oneObjectId, twoObjectId };

            var results = Client.Async.Delete(list).Result;

            foreach (var riakResult in results)
            {
                riakResult.IsSuccess.ShouldBeTrue(riakResult.ErrorMessage);
            }

            var oneResult = Client.Get(oneObjectId);
            oneResult.IsSuccess.ShouldBeFalse();
            oneResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            oneResult.Value.ShouldBeNull();

            var twoResult = Client.Get(twoObjectId);
            twoResult.IsSuccess.ShouldBeFalse();
            twoResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            twoResult.Value.ShouldBeNull();
        }
        public void ToRiakObjectIdProducesAValidRiakObjectId()
        {
            var riakObject = new RiakObject(Bucket, Key, "value");
            var riakObjectId = riakObject.ToRiakObjectId();

            riakObjectId.Bucket.ShouldEqual(Bucket);
            riakObjectId.Key.ShouldEqual(Key);
        }
示例#9
0
        public void ToRiakObjectIdProducesAValidRiakObjectId()
        {
            var riakObject   = new RiakObject(Bucket, Key, "value");
            var riakObjectId = riakObject.ToRiakObjectId();

            riakObjectId.Bucket.ShouldEqual(Bucket);
            riakObjectId.Key.ShouldEqual(Key);
        }
示例#10
0
        public void AsyncDeleteIsSuccessful()
        {
            var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);
            putResult.ShouldNotBeNull();

            var deletedObjectId = Client.Async.Delete(riakObjectId).ConfigureAwait(false).GetAwaiter().GetResult();

            var getResult = Client.Get(riakObjectId);
            getResult.ShouldBeNull();
        }
        public void AsyncGetWithRiakObjectIdReturnsData()
        {
            var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            Client.Put(riakObject);

            var result = Client.Async.Get(riakObjectId).Result;

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            result.Value.ShouldNotBeNull();
            result.Value.Bucket.ShouldEqual(TestBucket);
            result.Value.Key.ShouldEqual(TestKey);
            result.Value.Value.FromRiakString().ShouldEqual(TestJson);
        }
示例#12
0
        public void AsyncDeleteIsSuccessful()
        {
            var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);

            putResult.ShouldNotBeNull();

            var deletedObjectId = Client.Async.Delete(riakObjectId).ConfigureAwait(false).GetAwaiter().GetResult();

            var getResult = Client.Get(riakObjectId);

            getResult.ShouldBeNull();
        }
示例#13
0
        public void DeleteIsSuccessful()
        {
            var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);

            putResult.ShouldNotBeNull();

            Client.Delete(riakObjectId).ShouldNotBeNull();

            var getResult = Client.Get(riakObjectId);

            getResult.ShouldBeNull();
        }
        public void DeleteIsSuccessful()
        {
            var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);
            putResult.IsSuccess.ShouldBeTrue(putResult.ErrorMessage);

            var delResult = Client.Delete(riakObjectId);
            delResult.IsSuccess.ShouldBeTrue(delResult.ErrorMessage);

            var getResult = Client.Get(riakObjectId);
            getResult.IsSuccess.ShouldBeFalse(getResult.ErrorMessage);
            getResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            getResult.Value.ShouldBeNull();
        }
示例#15
0
        public void IndexesAreSavedWithAnObject()
        {
            var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");
            o.AddIndex("tacos", "are great!");
            o.AddIndex("age", 12);

            Client.Put(o);

            var result = Client.Get(o.ToRiakObjectId());

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            var ro = result.Value;

            ro.BinIndexes.Count.ShouldEqual(1);
            ro.IntIndexes.Count.ShouldEqual(1);
        }
示例#16
0
        public void TestKVOperations()
        {
            string key = Guid.NewGuid().ToString();
            var    id  = new RiakObjectId(TestBucketType, TestBucket, key);
            var    obj = new RiakObject(id, Value);

            // put
            var putOptions = new RiakPutOptions();

            putOptions.SetReturnBody(true);
            putOptions.SetDw(3);
            putOptions.SetTimeout(new Timeout(TimeSpan.FromSeconds(60)));
            var putResult = Client.Put(obj, putOptions);

            Assert.True(putResult.IsSuccess, putResult.ErrorMessage);
            Assert.AreEqual(TestBucketType, putResult.Value.BucketType);

            // get
            var getResult = Client.Get(id);

            Assert.True(getResult.IsSuccess);
            Assert.AreEqual(TestBucketType, getResult.Value.BucketType);

            // delete
            var deleteOptions = new RiakDeleteOptions();

            deleteOptions.Vclock = getResult.Value.VectorClock;
            deleteOptions.SetDw(3);
            var deleteResult = Client.Delete(id, new RiakDeleteOptions().SetDw(3));

            Assert.True(deleteResult.IsSuccess);

            // multiget
            var ids = new List <RiakObjectId>();

            for (int i = 0; i < 3; i++)
            {
                obj = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key + i), Value);
                Client.Put(obj, new RiakPutOptions().SetReturnBody(false).SetDw(3));
                ids.Add(obj.ToRiakObjectId());
            }

            var multiGetResult = Client.Get(ids).ToList();

            Assert.True(multiGetResult.All(r => r.IsSuccess));
            Assert.True(multiGetResult.All(r => r.Value.BucketType == TestBucketType));
        }
示例#17
0
        public void AsyncGetWithRiakObjectIdReturnsData()
        {
            var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            Client.Put(riakObject);

            var result = Client.Async.Get(riakObjectId).ConfigureAwait(false).GetAwaiter().GetResult();

            result.IsLeft.ShouldBeFalse();

            var updatedRiakObject = result.Right;

            updatedRiakObject.Bucket.ShouldEqual(TestBucket);
            updatedRiakObject.Key.ShouldEqual(TestKey);
            updatedRiakObject.Value.FromRiakString().ShouldEqual(TestJson);
        }
示例#18
0
        public void DeleteIsSuccessfulInBatch()
        {
            Client.Batch(batch =>
            {
                var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
                var riakObjectId = riakObject.ToRiakObjectId();

                var putResult = batch.Put(riakObject);
                putResult.ShouldNotBeNull();

                var delResult = batch.Delete(riakObjectId);
                delResult.ShouldNotBeNull();

                var getResult = batch.Get(riakObjectId);
                getResult.ShouldBeNull();
            });
        }
示例#19
0
        public void IndexesAreSavedWithAnObject()
        {
            var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");

            o.AddBinIndex("tacos", "are great!");
            o.AddIntIndex("age", 12);

            Client.Put(o);

            var result = Client.Get(o.ToRiakObjectId());

            result.IsSuccess.ShouldBeTrue();
            var ro = result.Value;

            ro.BinIndexes.Count.ShouldEqual(1);
            ro.IntIndexes.Count.ShouldEqual(1);
        }
示例#20
0
        public void IndexesAreSavedWithAnObject()
        {
            var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");

            o.BinIndex("tacos").Set("are great!");
            o.IntIndex("age").Set(12);

            Client.Put(o);

            var result = Client.Get(o.ToRiakObjectId());

            result.BinIndexes.Count.ShouldEqual(1);
            result.IntIndexes.Count.ShouldEqual(1);

            result.BinIndex("tacos").Values[0].ShouldEqual("are great!");
            result.IntIndex("age").Values[0].ShouldEqual(12);
        }
        public void AsyncDeleteIsSuccessful()
        {
            var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);

            putResult.IsSuccess.ShouldBeTrue(putResult.ErrorMessage);

            var result = Client.Async.Delete(riakObjectId).Result;

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);

            var getResult = Client.Get(riakObjectId);

            getResult.IsSuccess.ShouldBeFalse();
            getResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            getResult.Value.ShouldBeNull();
        }
        public void AsyncDeleteMultipleIsSuccessful()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            IEnumerable <RiakResult> theResults = null;

            var list = new List <RiakObjectId> {
                oneObjectId, twoObjectId
            };

            var resetEvent = new AutoResetEvent(false);

            Client.Async.Delete(list, results =>
            {
                theResults = results;
                resetEvent.Set();
            });
            resetEvent.WaitOne();

            foreach (var riakResult in theResults)
            {
                riakResult.IsSuccess.ShouldBeTrue();
            }

            var oneResult = Client.Get(oneObjectId);

            oneResult.IsSuccess.ShouldBeFalse();
            oneResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            oneResult.Value.ShouldBeNull();

            var twoResult = Client.Get(twoObjectId);

            twoResult.IsSuccess.ShouldBeFalse();
            twoResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            twoResult.Value.ShouldBeNull();
        }
        public void DeleteIsSuccessfulInBatch()
        {
            Client.Batch(batch =>
            {
                var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
                var riakObjectId = riakObject.ToRiakObjectId();

                var putResult = batch.Put(riakObject);
                putResult.IsSuccess.ShouldBeTrue(putResult.ErrorMessage);

                var delResult = batch.Delete(riakObjectId);
                delResult.IsSuccess.ShouldBeTrue(delResult.ErrorMessage);

                var getResult = batch.Get(riakObjectId);
                getResult.IsSuccess.ShouldBeFalse();
                getResult.ResultCode.ShouldEqual(ResultCode.NotFound);
                getResult.Value.ShouldBeNull();
            });
        }
示例#24
0
        public void AsyncGetMultipleReturnsAllObjects()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List <RiakObjectId> {
                oneObjectId, twoObjectId
            };

            var results = Client.Async.Get(list)
                          .ToEnumerable()
                          .ToList();

            results.Count().ShouldEqual(2);
        }
示例#25
0
        public void TestKVOperations()
        {
            string key = Guid.NewGuid().ToString();
            var id = new RiakObjectId(TestBucketType, TestBucket, key);
            var obj = new RiakObject(id, Value);

            // put
            var putOptions = new RiakPutOptions();
            putOptions.SetReturnBody(true);
            putOptions.SetDw(3);
            putOptions.SetTimeout(new Timeout(TimeSpan.FromSeconds(60)));
            var putResult = Client.Put(obj, putOptions);
            Assert.True(putResult.IsSuccess, putResult.ErrorMessage);
            Assert.AreEqual(TestBucketType, putResult.Value.BucketType);

            // get
            var getResult = Client.Get(id);
            Assert.True(getResult.IsSuccess);
            Assert.AreEqual(TestBucketType, getResult.Value.BucketType);

            // delete
            var deleteOptions = new RiakDeleteOptions();
            deleteOptions.Vclock = getResult.Value.VectorClock;
            deleteOptions.SetDw(3);
            var deleteResult = Client.Delete(id, new RiakDeleteOptions().SetDw(3));
            Assert.True(deleteResult.IsSuccess);

            // multiget
            var ids = new List<RiakObjectId>();
            for (int i = 0; i < 3; i++)
            {
                obj = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key + i), Value);
                Client.Put(obj, new RiakPutOptions().SetReturnBody(false).SetDw(3));
                ids.Add(obj.ToRiakObjectId());
            }

            var multiGetResult = Client.Get(ids).ToList();
            Assert.True(multiGetResult.All(r => r.IsSuccess));
            Assert.True(multiGetResult.All(r => r.Value.BucketType == TestBucketType));
        }
        public void AsyncDeleteMultipleIsSuccessful()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            IEnumerable<RiakResult> theResults = null;

            var list = new List<RiakObjectId> { oneObjectId, twoObjectId };

            var resetEvent = new AutoResetEvent(false);

            Client.Async.Delete(list, results =>
                                    {
                                        theResults = results;
                                        resetEvent.Set();
                                    });
            resetEvent.WaitOne();

            foreach (var riakResult in theResults)
            {
                riakResult.IsSuccess.ShouldBeTrue();
            }

            var oneResult = Client.Get(oneObjectId);
            oneResult.IsSuccess.ShouldBeFalse();
            oneResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            oneResult.Value.ShouldBeNull();

            var twoResult = Client.Get(twoObjectId);
            twoResult.IsSuccess.ShouldBeFalse();
            twoResult.ResultCode.ShouldEqual(ResultCode.NotFound);
            twoResult.Value.ShouldBeNull();
        }
示例#27
0
        public void TestKVOperations()
        {
            const string key = "bucket_type_test_key";
            var          id  = new RiakObjectId(TestBucketType, TestBucket, key);
            var          obj = new RiakObject(id, Value);

            // put
            var putResult = Client.Put(obj, new RiakPutOptions().SetReturnBody(true).SetDw(3));

            putResult.IsSuccess.ShouldBeTrue();
            putResult.Value.BucketType.ShouldEqual(TestBucketType);

            // get
            var getResult = Client.Get(id);

            getResult.IsSuccess.ShouldBeTrue();
            getResult.Value.BucketType.ShouldEqual(TestBucketType);

            // delete
            var deleteResult = Client.Delete(id, new RiakDeleteOptions().SetDw(3));

            deleteResult.IsSuccess.ShouldBeTrue();

            // multiget
            var ids = new List <RiakObjectId>();

            for (int i = 0; i < 3; i++)
            {
                obj = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key + i), Value);
                Client.Put(obj, new RiakPutOptions().SetReturnBody(true).SetDw(3));
                ids.Add(obj.ToRiakObjectId());
            }

            var multiGetResult = Client.Get(ids).ToList();

            multiGetResult.All(r => r.IsSuccess).ShouldBeTrue();
            multiGetResult.All(r => r.Value.BucketType == TestBucketType).ShouldBeTrue();
        }
        public void AsyncGetMultipleReturnsAllObjects()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List <RiakObjectId> {
                oneObjectId, twoObjectId
            };

            var results = Client.Async.Get(list).Result;

            foreach (var result in results)
            {
                result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
                result.Value.ShouldNotBeNull();
            }
        }
        public void AsyncGetWithRiakObjectIdReturnsData()
        {
            var riakObject   = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            Client.Put(riakObject);

            RiakResult <RiakObject> theResult = null;
            var resetEvent = new AutoResetEvent(false);

            Client.Async.Get(riakObjectId, result =>
            {
                theResult = result;
                resetEvent.Set();
            });
            resetEvent.WaitOne();

            theResult.IsSuccess.ShouldBeTrue();
            theResult.Value.ShouldNotBeNull();
            theResult.Value.Bucket.ShouldEqual(TestBucket);
            theResult.Value.Key.ShouldEqual(TestKey);
            theResult.Value.Value.FromRiakString().ShouldEqual(TestJson);
        }
示例#30
0
        public void AsyncDeleteMultipleIsSuccessful()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one).ShouldNotBeNull();
            Client.Put(two).ShouldNotBeNull();

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List<RiakObjectId> { oneObjectId, twoObjectId };

            var deletedObjectIds = Client.Async.Delete(list)
                .ToEnumerable()
                .ToList();
            deletedObjectIds.Count().ShouldEqual(2);

            var oneResult = Client.Get(oneObjectId);
            oneResult.ShouldBeNull();

            var twoResult = Client.Get(twoObjectId);
            twoResult.ShouldBeNull();
        }
示例#31
0
        public void IndexesAreSavedWithAnObject()
        {
            var o = new RiakObject(Bucket, "the_object", "{ value: \"this is an object\" }");

            o.BinIndex("tacos").Set("are great!");
            o.IntIndex("age").Set(12);

            Client.Put(o);

            var result = Client.Get(o.ToRiakObjectId());

            result.BinIndexes.Count.ShouldEqual(1);
            result.IntIndexes.Count.ShouldEqual(1);

            result.BinIndex("tacos").Values[0].ShouldEqual("are great!");
            result.IntIndex("age").Values[0].ShouldEqual(12);
        }
示例#32
0
        public void AsyncGetWithRiakObjectIdReturnsData()
        {
            var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            Client.Put(riakObject);

            var result = Client.Async.Get(riakObjectId).ConfigureAwait(false).GetAwaiter().GetResult();
            result.IsLeft.ShouldBeFalse();

            var updatedRiakObject = result.Right;
            updatedRiakObject.Bucket.ShouldEqual(TestBucket);
            updatedRiakObject.Key.ShouldEqual(TestKey);
            updatedRiakObject.Value.FromRiakString().ShouldEqual(TestJson);
        }
        public void AsyncGetMultipleReturnsAllObjects()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List<RiakObjectId> {oneObjectId, twoObjectId};

            var results = Client.Async.Get(list).Result;

            foreach (var result in results)
            {
                result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
                result.Value.ShouldNotBeNull();
            }
        }
示例#34
0
        public void DeleteIsSuccessful()
        {
            var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            var putResult = Client.Put(riakObject);
            putResult.ShouldNotBeNull();

            Client.Delete(riakObjectId).ShouldNotBeNull();

            var getResult = Client.Get(riakObjectId);
            getResult.ShouldBeNull();
        }
示例#35
0
        public void DeleteIsSuccessfulInBatch()
        {
            Client.Batch(batch =>
                {
                    var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
                    var riakObjectId = riakObject.ToRiakObjectId();

                    var putResult = batch.Put(riakObject);
                    putResult.ShouldNotBeNull();

                    var delResult = batch.Delete(riakObjectId);
                    delResult.ShouldNotBeNull();

                    var getResult = batch.Get(riakObjectId);
                    getResult.ShouldBeNull();
                });
        }
示例#36
0
        public void AsyncGetMultipleReturnsAllObjects()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            var list = new List<RiakObjectId> {oneObjectId, twoObjectId};

            var results = Client.Async.Get(list)
                .ToEnumerable()
                .ToList();

            results.Count().ShouldEqual(2);
        }
        public void AsyncGetMultipleReturnsAllObjects()
        {
            var one = new RiakObject(TestBucket, "one", TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var two = new RiakObject(TestBucket, "two", TestJson, RiakConstants.ContentTypes.ApplicationJson);

            Client.Put(one);
            Client.Put(two);

            var oneObjectId = one.ToRiakObjectId();
            var twoObjectId = two.ToRiakObjectId();

            IEnumerable<RiakResult<RiakObject>> theResults = null;

            var list = new List<RiakObjectId> {oneObjectId, twoObjectId};

            var resetEvent = new AutoResetEvent(false);

            Client.Async.Get(list, results =>
                                 {
                                     theResults = results;
                                     resetEvent.Set();
                                 });
            resetEvent.WaitOne();

            foreach (var result in theResults)
            {
                result.IsSuccess.ShouldBeTrue();
                result.Value.ShouldNotBeNull();
            }
        }
        public void AsyncGetWithRiakObjectIdReturnsData()
        {
            var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            Client.Put(riakObject);

            RiakResult<RiakObject> theResult = null;
            var resetEvent = new AutoResetEvent(false);

            Client.Async.Get(riakObjectId, result =>
                                         {
                                             theResult = result;
                                             resetEvent.Set();
                                         });
            resetEvent.WaitOne();

            theResult.IsSuccess.ShouldBeTrue();
            theResult.Value.ShouldNotBeNull();
            theResult.Value.Bucket.ShouldEqual(TestBucket);
            theResult.Value.Key.ShouldEqual(TestKey);
            theResult.Value.Value.FromRiakString().ShouldEqual(TestJson);
        }
        public void AsyncGetWithRiakObjectIdReturnsData()
        {
            var riakObject = new RiakObject(TestBucket, TestKey, TestJson, RiakConstants.ContentTypes.ApplicationJson);
            var riakObjectId = riakObject.ToRiakObjectId();

            Client.Put(riakObject);

            var result = Client.Async.Get(riakObjectId).Result;

            result.IsSuccess.ShouldBeTrue(result.ErrorMessage);
            result.Value.ShouldNotBeNull();
            result.Value.Bucket.ShouldEqual(TestBucket);
            result.Value.Key.ShouldEqual(TestKey);
            result.Value.Value.FromRiakString().ShouldEqual(TestJson);
        }