Ejemplo n.º 1
0
        public void Can_Update_A_Hll()
        {
            string key = Guid.NewGuid().ToString();

            SaveHll(key);

            var add_3 = new RiakString("add_3");
            var adds  = new HashSet <string> {
                add_3
            };

            var update = new UpdateHll.Builder(adds)
                         .WithBucketType(BucketType)
                         .WithBucket(Bucket)
                         .WithKey(key)
                         .WithReturnBody(true)
                         .WithTimeout(TimeSpan.FromMilliseconds(20000))
                         .Build();

            RiakResult rslt = client.Execute(update);

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

            HllResponse response = update.Response;

            Assert.AreEqual(3, response.Cardinality);
        }
Ejemplo n.º 2
0
        internal static Cell FromTsCell(TsCell tsc)
        {
            if (tsc.boolean_valueSpecified)
            {
                return(new Cell <bool>(tsc.boolean_value));
            }
            else if (tsc.double_valueSpecified)
            {
                return(new Cell <double>(tsc.double_value));
            }
            else if (tsc.sint64_valueSpecified)
            {
                return(new Cell <long>(tsc.sint64_value));
            }
            else if (tsc.timestamp_valueSpecified)
            {
                return(new Cell <DateTime>(
                           DateTimeUtil.FromUnixTimeMillis(tsc.timestamp_value)));
            }
            else if (tsc.varchar_valueSpecified)
            {
                return(new Cell <string>(RiakString.FromBytes(tsc.varchar_value)));
            }

            return(new Cell());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KvCommandOptions"/> class.
        /// </summary>
        /// <param name="bucketType">The bucket type in Riak. Required.</param>
        /// <param name="bucket">The bucket in Riak. Required.</param>
        /// <param name="key">The key in Riak.</param>
        /// <param name="keyIsRequired">If <b>true</b> and no key given, an exception is thrown.</param>
        public KvCommandOptions(
            string bucketType,
            string bucket,
            string key,
            bool keyIsRequired)
        {
            if (string.IsNullOrEmpty(bucketType))
            {
                throw new ArgumentNullException("bucketType");
            }
            else
            {
                this.bucketType = bucketType;
            }

            if (string.IsNullOrEmpty(bucket))
            {
                throw new ArgumentNullException("bucket");
            }
            else
            {
                this.bucket = bucket;
            }

            if (keyIsRequired && string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }
            else
            {
                this.key = key;
            }
        }
Ejemplo n.º 4
0
        public void Should_Construct_PreflistResponse_From_Resp()
        {
            string node_name   = "node-foo";
            long   partitionId = long.MaxValue;

            var preflistItem = new RpbBucketKeyPreflistItem();

            preflistItem.node      = RiakString.ToBytes(node_name);
            preflistItem.partition = partitionId;
            preflistItem.primary   = true;

            var fetchResp = new RpbGetBucketKeyPreflistResp();

            fetchResp.preflist.Add(preflistItem);

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

            fetch.OnSuccess(fetchResp);

            Assert.AreEqual(1, fetch.Response.Value.Count());
        }
Ejemplo n.º 5
0
        public void Should_Build_Req()
        {
            var cmd = new Get.Builder()
                      .WithTable(Table)
                      .WithKey(Key)
                      .Build();

            Assert.AreEqual(MessageCode.TsGetResp, cmd.ExpectedCode);

            TsGetReq pb = (TsGetReq)cmd.ConstructPbRequest();

            Assert.AreEqual(Table, RiakString.FromBytes(pb.table));
            Assert.IsFalse(pb.timeoutSpecified);

            Assert.True(pb.key[0].boolean_valueSpecified);
            Assert.AreEqual(Cells0[0].AsObject, pb.key[0].boolean_value);

            Assert.True(pb.key[1].double_valueSpecified);
            Assert.AreEqual(Cells0[1].AsObject, pb.key[1].double_value);

            Assert.True(pb.key[2].sint64_valueSpecified);
            Assert.AreEqual(Cells0[2].AsObject, pb.key[2].sint64_value);

            var dt = (DateTime)Cells0[3].AsObject;

            Assert.True(pb.key[3].timestamp_valueSpecified);
            Assert.AreEqual(DateTimeUtil.ToUnixTimeMillis(dt), pb.key[3].timestamp_value);

            var s = RiakString.ToBytes((string)Cells0[4].AsObject);

            Assert.True(pb.key[4].varchar_valueSpecified);
            CollectionAssert.AreEqual(s, pb.key[4].varchar_value);
        }
        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]);
        }
Ejemplo n.º 7
0
 public MapOperation RemoveSet(RiakString key)
 {
     addToSets.Remove(key);
     removeFromSets.Remove(key);
     removeSets.Add(key);
     return(this);
 }
        public void Should_Construct_CounterResponse_From_DtUpdateResp()
        {
            var key     = new RiakString("riak_generated_key");
            var context = new RiakString("1234");

            var updateResp = new DtUpdateResp();

            updateResp.key           = key;
            updateResp.context       = context;
            updateResp.counter_value = DefaultIncrement;

            var update = new UpdateCounter.Builder(DefaultIncrement)
                         .WithBucketType(BucketType)
                         .WithBucket(Bucket)
                         .Build();

            update.OnSuccess(updateResp);

            CounterResponse response = update.Response;

            Assert.NotNull(response);
            Assert.AreEqual(key, response.Key);
            Assert.AreEqual(RiakString.ToBytes(context), response.Context);
            Assert.AreEqual(DefaultIncrement, response.Value);
        }
Ejemplo n.º 9
0
 public void Can_Construct_From_Null()
 {
     var rs = new RiakString((byte[])null);
     Assert.False(rs.HasValue);
     Assert.IsNull((byte[])rs);
     Assert.IsNull(rs.ToString());
 }
Ejemplo n.º 10
0
 internal TsColumnDescription ToTsColumn()
 {
     return(new TsColumnDescription
     {
         name = RiakString.ToBytes(name),
         type = (TsColumnType)type
     });
 }
Ejemplo n.º 11
0
        public void Can_Construct_From_Null()
        {
            var rs = new RiakString((byte[])null);

            Assert.False(rs.HasValue);
            Assert.IsNull((byte[])rs);
            Assert.IsNull(rs.ToString());
        }
Ejemplo n.º 12
0
        public Cell(object value, ColumnType valueType)
        {
            if (value == null)
            {
                isNull         = true;
                this.valueType = ColumnType.Null;
            }
            else
            {
                this.valueType = valueType;
                switch (valueType)
                {
                case ColumnType.Boolean:
                    booleanValue = Convert.ToBoolean(value);
                    break;

                case ColumnType.Double:
                    doubleValue = Convert.ToDouble(value);
                    break;

                case ColumnType.SInt64:
                    sint64Value = Convert.ToInt64(value);
                    break;

                case ColumnType.Timestamp:
                    if (value is DateTime)
                    {
                        timestampValue = DateTimeUtil.ToUnixTimeMillis((DateTime)value);
                    }
                    else
                    {
                        timestampValue = Convert.ToInt64(value);
                    }

                    break;

                case ColumnType.Varchar:
                case ColumnType.Blob:
                    var bytes = value as byte[];
                    if (bytes != null)
                    {
                        varcharValue = bytes;
                    }
                    else
                    {
                        var s = Convert.ToString(value);
                        varcharValue = RiakString.ToBytes(s);
                    }

                    break;

                default:
                    string msg = string.Format("Unknown value type: {0}", valueType);
                    throw new ArgumentException(msg);
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TimeseriesCommandOptions"/> class.
        /// </summary>
        /// <param name="table">The table in Riak TS. Required.</param>
        public TimeseriesCommandOptions(string table)
        {
            if (string.IsNullOrEmpty(table))
            {
                throw new ArgumentNullException("table");
            }

            this.table = table;
        }
Ejemplo n.º 14
0
                public void Add(RiakString key)
                {
                    if (key == null)
                    {
                        throw new ArgumentNullException("key");
                    }

                    this[key] = default(TValue);
                }
Ejemplo n.º 15
0
        public Cell(string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value", "Value must not be null.");
            }

            varcharValue = RiakString.ToBytes(value);
            valueType    = ColumnType.Varchar;
        }
Ejemplo n.º 16
0
        public void Can_Convert_To_Boolean_To_Indicate_Non_Null_Value()
        {
            var rs = new RiakString(testString);
            Assert.True(rs);
            Assert.True(rs.HasValue);

            rs = new RiakString((string)null);
            Assert.False(rs);
            Assert.False(rs.HasValue);
        }
Ejemplo n.º 17
0
            public MapOperation RemoveFromSet(RiakString key, IEnumerable <RiakString> values)
            {
                removeSets.Remove(key);

                foreach (var value in values)
                {
                    removeFromSets.Add(key, value);
                }

                return(this);
            }
Ejemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PreflistItem"/> class.
        /// </summary>
        /// <param name="node">A <see cref="RiakString"/> representing the node owning the partition.</param>
        /// <param name="id">The partition ID.</param>
        /// <param name="primary">Will be <b>true</b> if this is a primary node for the partition.</param>
        public PreflistItem(RiakString node, long id, bool primary)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            this.node    = node;
            this.id      = id;
            this.primary = primary;
        }
        public void Can_Convert_To_Boolean_To_Indicate_Non_Null_Value()
        {
            var rs = new RiakString(testString);

            Assert.True(rs);
            Assert.True(rs.HasValue);

            rs = new RiakString((string)null);
            Assert.False(rs);
            Assert.False(rs.HasValue);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PreflistItem"/> class.
        /// </summary>
        /// <param name="node">A <see cref="RiakString"/> representing the node owning the partition.</param>
        /// <param name="id">The partition ID.</param>
        /// <param name="primary">Will be <b>true</b> if this is a primary node for the partition.</param>
        public PreflistItem(RiakString node, long id, bool primary)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            this.node = node;
            this.id = id;
            this.primary = primary;
        }
Ejemplo n.º 21
0
 public void Increment(RiakString key, long increment)
 {
     if (this.ContainsKey(key))
     {
         this[key] += increment;
     }
     else
     {
         this[key] = increment;
     }
 }
Ejemplo n.º 22
0
            public void Add(RiakString key, byte[] value)
            {
                IList <byte[]> values = null;

                if (!this.TryGetValue(key, out values))
                {
                    values    = new List <byte[]>();
                    this[key] = values;
                }

                values.Add(value);
            }
Ejemplo n.º 23
0
        public void Are_Equatable()
        {
            TsCell c0 = new TsCell {
                boolean_value = Boolean0
            };
            TsCell c1 = new TsCell {
                boolean_value = Boolean0
            };

            Assert.AreEqual(c0, c1, string.Format("c0 {0} c1 {1}", c0, c1));

            c0 = new TsCell {
                double_value = Double0
            };
            c1 = new TsCell {
                double_value = Double0
            };
            Assert.AreEqual(c0, c1, string.Format("c0 {0} c1 {1}", c0, c1));

            c0 = new TsCell {
                sint64_value = Long0
            };
            c1 = new TsCell {
                sint64_value = Long0
            };
            Assert.AreEqual(c0, c1, string.Format("c0 {0} c1 {1}", c0, c1));

            var ut = DateTimeUtil.ToUnixTimeMillis(Timestamp0);

            c0 = new TsCell {
                timestamp_value = ut
            };
            c1 = new TsCell {
                timestamp_value = ut
            };
            Assert.AreEqual(c0, c1, string.Format("c0 {0} c1 {1}", c0, c1));

            c0 = new TsCell {
                varchar_value = RiakString.ToBytes(Varchar0)
            };
            c1 = new TsCell {
                varchar_value = RiakString.ToBytes(Varchar0)
            };
            Assert.AreEqual(c0, c1, string.Format("c0 {0} c1 {1}", c0, c1));

            c0 = new TsCell {
                varchar_value = Blob0
            };
            c1 = new TsCell {
                varchar_value = Blob0
            };
            Assert.AreEqual(c0, c1, string.Format("c0 {0} c1 {1}", c0, c1));
        }
Ejemplo n.º 24
0
            public IEnumerable <RiakString> GetValueAsRiakStrings(RiakString key)
            {
                IEnumerable <RiakString> valueAsRiakStrings = null;
                IList <byte[]>           value = null;

                if (TryGetValue(key, out value))
                {
                    valueAsRiakStrings = value.Select(v => RiakString.FromBytes(v));
                }

                return(valueAsRiakStrings);
            }
Ejemplo n.º 25
0
        public void Should_Build_Req_With_Timeout()
        {
            Get cmd = BuildGetReqWithTimeout();

            Assert.AreEqual(MessageCode.TsGetResp, cmd.ExpectedCode);

            TsGetReq pb = (TsGetReq)cmd.ConstructRequest(false);

            Assert.AreEqual(Table, RiakString.FromBytes(pb.table));

            Assert.IsTrue(pb.timeoutSpecified);
            Assert.AreEqual(Timeout.TotalMilliseconds, pb.timeout);
        }
Ejemplo n.º 26
0
            public RiakString GetValueAsRiakString(RiakString key)
            {
                RiakString valueAsRiakString = null;

                byte[] value = null;

                if (TryGetValue(key, out value))
                {
                    valueAsRiakString = new RiakString(value);
                }

                return(valueAsRiakString);
            }
Ejemplo n.º 27
0
            public long GetValue(RiakString key)
            {
                long value;

                if (TryGetValue(key, out value))
                {
                    return(value);
                }
                else
                {
                    return(default(long));
                }
            }
Ejemplo n.º 28
0
        public void Should_Build_Req()
        {
            var cmd = new ListKeys.Builder()
                      .WithTable(Table)
                      .Build();

            Assert.AreEqual(MessageCode.TsListKeysResp, cmd.ExpectedCode);

            TsListKeysReq pb = (TsListKeysReq)cmd.ConstructPbRequest();

            Assert.AreEqual(Table, RiakString.FromBytes(pb.table));
            Assert.IsFalse(pb.timeoutSpecified);
        }
        protected RiakString GetKey(RiakString optskey, RiakResp response)
        {
            RiakString key = optskey;

            IRpbGeneratedKey krsp = response as IRpbGeneratedKey;

            if (krsp != null && krsp.HasKey)
            {
                key = new RiakString(krsp.key);
            }

            return(key);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Response"/> class.
        /// </summary>
        /// <param name="key">A <see cref="RiakString"/> representing the key.</param>
        public Response(RiakString key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key", "key is required!");
            }
            else
            {
                this.key = key;
            }

            this.notFound = false;
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Response"/> class.
        /// </summary>
        /// <param name="key">A <see cref="RiakString"/> representing the key.</param>
        public Response(RiakString key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key", "key is required!");
            }
            else
            {
                this.key = key;
            }

            this.notFound = false;
        }
Ejemplo n.º 32
0
        public void Should_Build_Req()
        {
            Store cmd = BuildStoreReq();

            Assert.AreEqual(MessageCode.TsPutResp, cmd.ExpectedCode);

            TsPutReq pb = (TsPutReq)cmd.ConstructPbRequest();

            Assert.AreEqual(Table, RiakString.FromBytes(pb.table));

            CollectionAssert.AreEqual(TsCols, pb.columns);
            CollectionAssert.AreEqual(TsRows, pb.rows);
        }
Ejemplo n.º 33
0
        public override string Save(User model)
        {
            var mapOperation = new UpdateMap.MapOperation();

            mapOperation.SetRegister(firstNameRegister, model.FirstName);
            mapOperation.SetRegister(lastNameRegister, model.LastName);
            mapOperation.IncrementCounter(pageVisitsCounter, model.PageVisits);
            mapOperation.AddToSet(interestsSet, model.Interests);

            // Insert does not require context
            RiakString key = UpdateMap(model, mapOperation, fetchFirst: false);

            return((string)key);
        }
Ejemplo n.º 34
0
            public MapOperation Map(RiakString key)
            {
                removeMaps.Remove(key);

                MapOperation mapOp;

                if (!maps.TryGetValue(key, out mapOp))
                {
                    mapOp = new MapOperation();
                    maps.Add(key, mapOp);
                }

                return(mapOp);
            }
        public void Can_Update_A_Set()
        {
            string key = Guid.NewGuid().ToString();
            SetResponse resp = SaveSet(key);

            var add_3 = new RiakString("add_3");
            var adds = new HashSet<string> { add_3 };

            var add_1 = new RiakString("add_1");
            var removes = new HashSet<string> { add_1 };

            var update = new UpdateSet.Builder(adds, removes)
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .WithKey(key)
                .WithContext(resp.Context)
                .WithReturnBody(true)
                .WithTimeout(TimeSpan.FromMilliseconds(20000))
                .Build();

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

            SetResponse response = update.Response;
            bool found_add_1 = false;
            bool found_add_3 = false;
            foreach (RiakString value in response.Value)
            {
                if (value.Equals(add_1))
                {
                    found_add_1 = true;
                }

                if (value.Equals(add_3))
                {
                    found_add_3 = true;
                }
            }

            Assert.True(found_add_3);
            Assert.False(found_add_1);
        }
        public ServerInfo(RiakString node, RiakString serverVersion)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            else
            {
                this.node = node;
            }

            if (serverVersion == null)
            {
                throw new ArgumentNullException("serverVersion");
            }
            else
            {
                this.serverVersion = serverVersion;
            }
        }
Ejemplo n.º 37
0
        public void Should_Construct_HllResponse_From_DtUpdateResp()
        {
            var key = new RiakString("riak_generated_key");

            var updateResp = new DtUpdateResp();
            updateResp.key = key;
            updateResp.hll_value = 42;

            var update = new UpdateHll.Builder(DefaultAdds)
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .Build();

            update.OnSuccess(updateResp);

            HllResponse response = update.Response;

            Assert.NotNull(response);
            Assert.AreEqual(key, response.Key);
            Assert.AreEqual(42, response.Value);
        }
        public void Can_Update_A_Hll()
        {
            string key = Guid.NewGuid().ToString();
            SaveHll(key);

            var add_3 = new RiakString("add_3");
            var adds = new HashSet<string> { add_3 };

            var update = new UpdateHll.Builder(adds)
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .WithKey(key)
                .WithReturnBody(true)
                .WithTimeout(TimeSpan.FromMilliseconds(20000))
                .Build();

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

            HllResponse response = update.Response;
            Assert.AreEqual(3, response.Cardinality);
        }
        public void Should_Construct_CounterResponse_From_DtUpdateResp()
        {
            var key = new RiakString("riak_generated_key");
            var context = new RiakString("1234");

            var updateResp = new DtUpdateResp();
            updateResp.key = key;
            updateResp.context = context;
            updateResp.counter_value = DefaultIncrement;

            var update = new UpdateCounter.Builder(DefaultIncrement)
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .Build();

            update.OnSuccess(updateResp);

            CounterResponse response = update.Response;

            Assert.NotNull(response);
            Assert.AreEqual(key, response.Key);
            Assert.AreEqual(RiakString.ToBytes(context), response.Context);
            Assert.AreEqual(DefaultIncrement, response.Value);
        }
Ejemplo n.º 40
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]);
        }
Ejemplo n.º 41
0
        public void Should_Construct_SetResponse_From_DtUpdateResp()
        {
            var key = new RiakString("riak_generated_key");

            var updateResp = new DtUpdateResp();
            updateResp.key = key;
            updateResp.context = Context;
            updateResp.set_value.AddRange(DefaultAdds);

            var update = new UpdateSet.Builder(DefaultAdds, null)
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .Build();

            update.OnSuccess(updateResp);

            SetResponse response = update.Response;

            Assert.NotNull(response);
            Assert.AreEqual(key, response.Key);
            Assert.AreEqual(Context, response.Context);
            Assert.AreEqual(DefaultAdds, response.Value);
        }
        public void Should_Construct_MapResponse_From_DtFetchResp()
        {
            var key = new RiakString("riak_generated_key");
            var context = new RiakString("1234");

            var fetchResp = new DtFetchResp();
            fetchResp.type = DtFetchResp.DataType.MAP;
            fetchResp.value = new DtValue();
            fetchResp.context = context;

            Func<IEnumerable<MapEntry>> createMapEntries = () =>
            {
                var mapEntries = new List<MapEntry>();

                var mapField = new MapField();
                mapField.type = MapField.MapFieldType.COUNTER;
                mapField.name = new RiakString("counter_1");
                var mapEntry = new MapEntry();
                mapEntry.field = mapField;
                mapEntry.counter_value = 50;
                mapEntries.Add(mapEntry);

                mapField = new MapField();
                mapField.type = MapField.MapFieldType.SET;
                mapField.name = new RiakString("set_1");
                mapEntry = new MapEntry();
                mapEntry.field = mapField;
                mapEntry.set_value.Add(RiakString.ToBytes("value_1"));
                mapEntry.set_value.Add(RiakString.ToBytes("value_2"));
                mapEntries.Add(mapEntry);

                mapField = new MapField();
                mapField.type = MapField.MapFieldType.REGISTER;
                mapField.name = new RiakString("register_1");
                mapEntry = new MapEntry();
                mapEntry.field = mapField;
                mapEntry.register_value = RiakString.ToBytes("1234");
                mapEntries.Add(mapEntry);

                mapField = new MapField();
                mapField.type = MapField.MapFieldType.FLAG;
                mapField.name = new RiakString("flag_1");
                mapEntry = new MapEntry();
                mapEntry.field = mapField;
                mapEntry.flag_value = true;
                mapEntries.Add(mapEntry);

                return mapEntries;
            };

            fetchResp.value.map_value.AddRange(createMapEntries());

            var map_1_field = new MapField();
            map_1_field.type = MapField.MapFieldType.MAP;
            map_1_field.name = new RiakString("map_1");
            var map_1_entry = new MapEntry();
            map_1_entry.field = map_1_field;
            map_1_entry.map_value.AddRange(createMapEntries());

            fetchResp.value.map_value.Add(map_1_entry);

            Action<Map> verifyMap = (map) =>
            {
                Assert.AreEqual(50, map.Counters["counter_1"]);
                Assert.AreEqual(RiakString.ToBytes("value_1"), map.Sets["set_1"][0]);
                Assert.AreEqual(RiakString.ToBytes("value_2"), map.Sets["set_1"][1]);
                Assert.AreEqual(RiakString.ToBytes("1234"), map.Registers["register_1"]);
                Assert.IsTrue(map.Flags["flag_1"]);
            };

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

            fetch.OnSuccess(fetchResp);

            MapResponse response = fetch.Response;

            Assert.NotNull(response);
            Assert.AreEqual(key, response.Key);
            Assert.AreEqual(RiakString.ToBytes(context), response.Context);

            verifyMap(response.Value);
            verifyMap(response.Value.Maps["map_1"]);
        }
Ejemplo n.º 43
0
 public void Can_Construct_From_Byte_Array()
 {
     var rs = new RiakString(testBytes);
     Assert.AreEqual(testBytes, (byte[])rs);
 }
Ejemplo n.º 44
0
 public void Can_Cast_To_Byte_Array()
 {
     var rs = new RiakString(testString);
     Assert.AreEqual(testBytes, (byte[])rs);
 }