From 907daff274cd11b7b646e5670d1eb4cf0c478070 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Tue, 2 Jul 2024 19:24:15 +0500 Subject: [PATCH] Add interoperabilty tests for Unregistered message --- .../messages/unregistered_test.dart | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/interoptests/messages/unregistered_test.dart diff --git a/test/interoptests/messages/unregistered_test.dart b/test/interoptests/messages/unregistered_test.dart new file mode 100644 index 0000000..d9b884b --- /dev/null +++ b/test/interoptests/messages/unregistered_test.dart @@ -0,0 +1,50 @@ +import "package:pinenacl/encoding.dart"; +import "package:test/test.dart"; + +import "package:wampproto/messages.dart"; +import "package:wampproto/serializers.dart"; + +import "../helper.dart"; + +void main() { + const baseUnRegCmd = "message unregistered 1"; + + group("UnRegistered", () { + bool isEqual(UnRegistered msg1, UnRegistered msg2) => msg1.requestID == msg2.requestID; + + test("JSONSerializer", () async { + var msg = UnRegistered(1); + var command = "$baseUnRegCmd --serializer json"; + + var output = await runCommand(command); + + var jsonSerializer = JSONSerializer(); + var message = jsonSerializer.deserialize(output) as UnRegistered; + expect(isEqual(message, msg), true); + }); + + test("CBORSerializer", () async { + var msg = UnRegistered(1); + var command = "$baseUnRegCmd --serializer cbor --output hex"; + + var output = await runCommand(command); + var outputBytes = Base16Encoder.instance.decode(output.trim()); + + var cborSerializer = CBORSerializer(); + var message = cborSerializer.deserialize(outputBytes) as UnRegistered; + expect(isEqual(message, msg), true); + }); + + test("MsgPackSerializer", () async { + var msg = UnRegistered(1); + var command = "$baseUnRegCmd --serializer msgpack --output hex"; + + var output = await runCommand(command); + var outputBytes = Base16Encoder.instance.decode(output.trim()); + + var msgPackSerializer = MsgPackSerializer(); + var message = msgPackSerializer.deserialize(outputBytes) as UnRegistered; + expect(isEqual(message, msg), true); + }); + }); +}