public void testGetMessageType() { WriteSchemaV0_6 testProtocol = WriteSchema.v0_6(schemaName, schemaVersion, attr1); string msgName = "msg name"; Assert.AreEqual( Util.getMessageType(Util.EVERNYM_MSG_QUALIFIER, testProtocol.family(), testProtocol.version(), msgName), testProtocol.messageType(msgName)); }
public void testWrite() { withContext(context => { WriteSchemaV0_6 testProtocol = WriteSchema.v0_6(schemaName, schemaVersion, attr1, attr2); byte[] message = testProtocol.writeMsgPacked(context); JsonObject unpackedMessage = TestHelpers.unpackForwardMessage(context, message); testBaseMessage(unpackedMessage); Assert.AreEqual( "did:sov:123456789abcdefghi1234;spec/write-schema/0.6/write", unpackedMessage.getAsString("@type") ); }); }
public void testWrite() { withContext(context => { WriteSchemaV0_6 testProtocol = WriteSchema.v0_6(schemaName, schemaVersion, attr1, attr2); byte[] message = testProtocol.writeMsgPacked(context); JsonObject unpackedMessage = TestHelpers.unpackForwardMessage(context, message); testBaseMessage(unpackedMessage); Assert.AreEqual( Util.EVERNYM_MSG_QUALIFIER + "/write-schema/0.6/write", unpackedMessage.getAsString("@type") ); }); }
void DoWriteLedgerSchema() { // input parameters for schema string schemaName = "Diploma " + Guid.NewGuid().ToString().Substring(0, 8); string schemaVersion = "0.1"; // constructor for the Write Schema protocol WriteSchemaV0_6 writeSchema = WriteSchema.v0_6(schemaName, schemaVersion, "name", "degree"); writeSchemaHandler(writeSchema); // request schema be written to ledger writeSchema.write(context); // wait for operation to be complete WaitFor(ref schemaComplete, "Waiting to write schema to ledger"); }
public void testConstructor() { Context context = TestHelpers.getContext(); WriteSchemaV0_6 writeSchema = WriteSchema.v0_6(schemaName, schemaVersion, attr1, attr2); JsonObject msg = writeSchema.writeMsg(context); Assert.AreEqual(schemaName, msg.getAsString("name")); Assert.AreEqual(schemaVersion, msg.getAsString("version")); var attrs = (new List <string>() { attr1, attr2 }); var msg_attrs = msg.getAsJsonArray("attrNames").Select(s => s.ToString().Trim('"')).ToList(); Assert.IsTrue(attrs.EquivalentTo(msg_attrs)); }
void writeSchemaHandler(WriteSchemaV0_6 handler) { // handler for message received when schema is written handlers.addHandler( handler, (msgName, message) => { if ("status-report".Equals(msgName)) { App.consolePrintMessage(msgName, message); _schemaIdRef = message["schemaId"]; schemaComplete = true; } else { nonHandled(msgName, message); } } ); }
public void testConstructor() { Context context = TestHelpers.getContext(); WriteSchemaV0_6 writeSchema = WriteSchema.v0_6(schemaName, schemaVersion, attr1, attr2); JsonObject msg = writeSchema.writeMsg(context); Assert.AreEqual(schemaName, msg.getAsString("name")); Assert.AreEqual(schemaVersion, msg.getAsString("version")); var attrs = (new List <string>() { attr1, attr2 }); var msg_attrs = msg.getAsJsonArray("attrNames").Select(s => s.ToString().Trim('"')).ToList(); Assert.IsTrue(attrs.EquivalentTo(msg_attrs)); // assert invalid arguments throw an exception Assert.ThrowsException <ArgumentException>(() => WriteSchema.v0_6(null, schemaVersion, attr1, attr2) ); Assert.ThrowsException <ArgumentException>(() => WriteSchema.v0_6("", schemaVersion, attr1, attr2) ); Assert.ThrowsException <ArgumentException>(() => WriteSchema.v0_6(schemaName, null, attr1, attr2) ); Assert.ThrowsException <ArgumentException>(() => WriteSchema.v0_6(schemaName, "", attr1, attr2) ); Assert.ThrowsException <ArgumentException>(() => WriteSchema.v0_6(schemaName, schemaVersion, null) ); Assert.ThrowsException <ArgumentException>(() => WriteSchema.v0_6(schemaName, schemaVersion, attr1, null) ); }
public void testGetThreadId() { WriteSchemaV0_6 testProtocol = WriteSchema.v0_6(schemaName, schemaVersion, attr1); Assert.IsNotNull(testProtocol.getThreadId()); }