public void Should_Construct_SetResponse_From_DtFetchResp()
        {
            var set_item_1 = new RiakString("set_item_1");
            var set_item_2 = new RiakString("set_item_2");
            var value      = new DtValue();

            value.set_value.Add(set_item_1);
            value.set_value.Add(set_item_2);

            var fetchResp = new DtFetchResp();

            fetchResp.value = value;
            fetchResp.type  = DtFetchResp.DataType.SET;

            var fetch = new FetchSet.Builder()
                        .WithBucketType(BucketType)
                        .WithBucket(Bucket)
                        .WithKey(Key)
                        .Build();

            fetch.OnSuccess(fetchResp);

            var itemList = fetch.Response.Value.Select(v => new RiakString(v)).ToList();

            Assert.AreEqual(set_item_1, itemList[0]);
            Assert.AreEqual(set_item_2, itemList[1]);
        }
Пример #2
0
        public void Fetching_An_Unknown_Set_Results_In_Not_Found()
        {
            var fetch = new FetchSet.Builder()
                        .WithBucketType(BucketType)
                        .WithBucket(Bucket)
                        .WithKey(Guid.NewGuid().ToString())
                        .Build();

            RiakResult rslt = client.Execute(fetch);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);
            SetResponse response = fetch.Response;

            Assert.IsTrue(response.NotFound);
        }
        public void Fetching_A_Set_Produces_Expected_Values()
        {
            string key = Guid.NewGuid().ToString();
            SaveSet(key);

            var fetch = new FetchSet.Builder()
                    .WithBucketType(BucketType)
                    .WithBucket(Bucket)
                    .WithKey(key)
                    .Build();

            RiakResult rslt = client.Execute(fetch);
            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            SetResponse response = fetch.Response;
            Assert.IsNotNull(response);

            Assert.IsNotNull(response.Context);
            Assert.IsNotEmpty(response.Context);
            Assert.AreEqual(DefaultAdds, response.Value);
        }
Пример #4
0
        public void InitialSetIsEmpty()
        {
            var builder = new FetchSet.Builder()
                          .WithBucketType("sets")
                          .WithBucket("travel")
                          .WithKey("cities");

            // NB: builder.Options will only be set after Build() is called.
            FetchSet fetchSetCommand = builder.Build();

            FetchSetOptions options = new FetchSetOptions("sets", "travel", "cities");

            Assert.AreEqual(options, builder.Options);

            RiakResult rslt = client.Execute(fetchSetCommand);

            CheckResult(rslt);

            SetResponse response = fetchSetCommand.Response;

            Assert.IsTrue(EnumerableUtil.IsNullOrEmpty(response.Value));
        }
        public void Should_Build_DtFetchReq_Correctly()
        {
            var fetch = new FetchSet.Builder()
                        .WithBucketType(BucketType)
                        .WithBucket(Bucket)
                        .WithKey(Key)
                        .WithR((Quorum)1)
                        .WithPR((Quorum)2)
                        .WithNotFoundOK(true)
                        .WithBasicQuorum(true)
                        .WithTimeout(TimeSpan.FromMilliseconds(20000))
                        .Build();

            DtFetchReq protobuf = (DtFetchReq)fetch.ConstructPbRequest();

            Assert.AreEqual(BucketType, RiakString.FromBytes(protobuf.type));
            Assert.AreEqual(Bucket, RiakString.FromBytes(protobuf.bucket));
            Assert.AreEqual(Key, RiakString.FromBytes(protobuf.key));
            Assert.AreEqual(1, protobuf.r);
            Assert.AreEqual(2, protobuf.pr);
            Assert.AreEqual(true, protobuf.notfound_ok);
            Assert.AreEqual(true, protobuf.basic_quorum);
            Assert.AreEqual(20000, protobuf.timeout);
        }
Пример #6
0
        public void Should_Construct_SetResponse_From_DtFetchResp()
        {
            var set_item_1 = new RiakString("set_item_1");
            var set_item_2 = new RiakString("set_item_2");
            var value = new DtValue();
            value.set_value.Add(set_item_1);
            value.set_value.Add(set_item_2);

            var fetchResp = new DtFetchResp();
            fetchResp.value = value;
            fetchResp.type = DtFetchResp.DataType.SET;

            var fetch = new FetchSet.Builder()
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .WithKey(Key)
                .Build();

            fetch.OnSuccess(fetchResp);

            var itemList = fetch.Response.Value.Select(v => new RiakString(v)).ToList();
            Assert.AreEqual(set_item_1, itemList[0]);
            Assert.AreEqual(set_item_2, itemList[1]);
        }
Пример #7
0
        public void Should_Build_DtFetchReq_Correctly()
        {
            var fetch = new FetchSet.Builder()
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .WithKey(Key)
                .WithR((Quorum)1)
                .WithPR((Quorum)2)
                .WithNotFoundOK(true)
                .WithBasicQuorum(true)
                .WithTimeout(TimeSpan.FromMilliseconds(20000))
                .Build();

            DtFetchReq protobuf = (DtFetchReq)fetch.ConstructRequest(false);

            Assert.AreEqual(BucketType, RiakString.FromBytes(protobuf.type));
            Assert.AreEqual(Bucket, RiakString.FromBytes(protobuf.bucket));
            Assert.AreEqual(Key, RiakString.FromBytes(protobuf.key));
            Assert.AreEqual(1, protobuf.r);
            Assert.AreEqual(2, protobuf.pr);
            Assert.AreEqual(true, protobuf.notfound_ok);
            Assert.AreEqual(true, protobuf.basic_quorum);
            Assert.AreEqual(20000, protobuf.timeout);
        }
Пример #8
0
        public void Fetching_A_Set_Produces_Expected_Values()
        {
            string key = Guid.NewGuid().ToString();

            SaveSet(key);

            var fetch = new FetchSet.Builder()
                        .WithBucketType(BucketType)
                        .WithBucket(Bucket)
                        .WithKey(key)
                        .Build();

            RiakResult rslt = client.Execute(fetch);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            SetResponse response = fetch.Response;

            Assert.IsNotNull(response);

            Assert.IsNotNull(response.Context);
            Assert.IsNotEmpty(response.Context);
            Assert.AreEqual(DefaultAdds, response.Value);
        }
        public void Fetching_An_Unknown_Set_Results_In_Not_Found()
        {
            var fetch = new FetchSet.Builder()
                    .WithBucketType(BucketType)
                    .WithBucket(Bucket)
                    .WithKey(Guid.NewGuid().ToString())
                    .Build();

            RiakResult rslt = client.Execute(fetch);
            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);
            SetResponse response = fetch.Response;
            Assert.IsTrue(response.NotFound);
        }
        public void InitialSetIsEmpty()
        {
            var builder = new FetchSet.Builder()
                .WithBucketType("sets")
                .WithBucket("travel")
                .WithKey("cities");

            // NB: builder.Options will only be set after Build() is called.
            FetchSet fetchSetCommand = builder.Build();

            FetchSetOptions options = new FetchSetOptions("sets", "travel", "cities");
            Assert.AreEqual(options, builder.Options);

            RiakResult rslt = client.Execute(fetchSetCommand);
            CheckResult(rslt);

            SetResponse response = fetchSetCommand.Response;
            Assert.IsTrue(EnumerableUtil.IsNullOrEmpty(response.Value));
        }