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()); }
public override void OnSuccess(RpbResp response) { if (response == null) { Response = new PreflistResponse(); } else { RpbGetBucketKeyPreflistResp resp = (RpbGetBucketKeyPreflistResp)response; IEnumerable <PreflistItem> preflistItems = Enumerable.Empty <PreflistItem>(); if (EnumerableUtil.NotNullOrEmpty(resp.preflist)) { preflistItems = resp.preflist.Select(i => new PreflistItem(RiakString.FromBytes(i.node), i.partition, i.primary)); } Response = new PreflistResponse(Options.Key, preflistItems); } }