public void TestGetPrivateDataByRange() { ChaincodeStub stub = new ChaincodeStub("myc", "txId", handler.Object, new List <ByteString>(), null); string startKey = "START"; string endKey = "END"; KV[] keyValues = new KV[] { new KV { Key = "A", Value = ByteString.CopyFromUtf8("Value of A") }, new KV { Key = "B", Value = ByteString.CopyFromUtf8("Value of B") } }; QueryResponse value = new QueryResponse { HasMore = false }; value.Results.Add(new QueryResultBytes { ResultBytes = keyValues[0].ToByteString() }); value.Results.Add(new QueryResultBytes { ResultBytes = keyValues[1].ToByteString() }); handler.Setup(a => a.GetStateByRangeAsync("myc", "txId", "testcoll", startKey, endKey, null, token)).ReturnsAsync(value); Assert.That.Contains(stub.GetPrivateDataByRange("testcoll", startKey, endKey), keyValues.Select(a => new KeyValue(a))); try { stub.GetPrivateDataByRange(null, startKey, endKey); Assert.Fail("Null collection check fails"); } catch (ArgumentException) { //ignored } try { stub.GetPrivateDataByRange("", startKey, endKey); Assert.Fail("Empty collection check fails"); } catch (ArgumentException) { //ignored } }