public void TestGetQueryResult()
        {
            ChaincodeStub stub = new ChaincodeStub("myc", "txId", handler.Object, new List <ByteString>(), null);

            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.GetQueryResultAsync("myc", "txId", "", "QUERY", null, token)).ReturnsAsync(value);
            Assert.That.Contains(stub.GetQueryResult("QUERY"), keyValues.Select(a => new KeyValue(a)));
        }
        public void TestGetPrivateDataQueryResult()
        {
            ChaincodeStub stub = new ChaincodeStub("myc", "txId", handler.Object, new List <ByteString>(), null);

            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.GetQueryResultAsync("myc", "txId", "testcoll", "QUERY", null, token)).ReturnsAsync(value);

            Assert.That.Contains(stub.GetPrivateDataQueryResult("testcoll", "QUERY"), keyValues.Select(a => new KeyValue(a)));

            try
            {
                stub.GetPrivateDataQueryResult(null, "QUERY");
                Assert.Fail("Null collection check fails");
            }
            catch (ArgumentException)
            {
                //ignored
            }

            try
            {
                stub.GetPrivateDataQueryResult("", "QUERY");
                Assert.Fail("Empty collection check fails");
            }
            catch (ArgumentException)
            {
                //ignored
            }
        }