public void TestGetPrivateDataValidationParameter() { ChaincodeStub stub = new ChaincodeStub("myc", "txId", handler.Object, new List <ByteString>(), null); byte[] value = new byte[] { 0x10, 0x20, 0x30 }; Dictionary <string, ByteString> metaMap = new Dictionary <string, ByteString>(); metaMap[ChaincodeStub.VALIDATION_PARAMETER] = ByteString.CopyFrom(value); handler.Setup(a => a.GetStateMetadataAsync("myc", "txId", "testcoll", "key", token)).ReturnsAsync(metaMap); CollectionAssert.AreEqual(stub.GetPrivateDataValidationParameter("testcoll", "key"), value); handler.Setup(a => a.GetStateMetadataAsync("myc", "txId", "testcoll", "key2", token)).ReturnsAsync(new Dictionary <string, ByteString>()); Assert.IsNull(stub.GetPrivateDataValidationParameter("testcoll", "key2")); try { stub.GetPrivateDataValidationParameter(null, "key"); Assert.Fail("Null collection check fails"); } catch (ArgumentException) { //ignored } try { stub.GetPrivateDataValidationParameter("", "key"); Assert.Fail("Empty collection check fails"); } catch (ArgumentException) { //ignored } }