From 621cc02f73ad225d411e772bf5cf1316fc7be871 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Tue, 2 Jul 2024 19:02:48 +0500 Subject: [PATCH] Add interoperabilty tests for Unsubscribed message --- test/interoptests/messages/event_test.dart | 8 +-- .../interoptests/messages/subscribe_test.dart | 2 +- .../messages/subscribed_test.dart | 2 +- .../messages/unsubscribed_test.dart | 50 +++++++++++++++++++ 4 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 test/interoptests/messages/unsubscribed_test.dart diff --git a/test/interoptests/messages/event_test.dart b/test/interoptests/messages/event_test.dart index 67df4e1..42bb0cb 100644 --- a/test/interoptests/messages/event_test.dart +++ b/test/interoptests/messages/event_test.dart @@ -14,10 +14,10 @@ void main() { bool isEqual(Event msg1, Event msg2) => msg1.subscriptionID == msg2.subscriptionID && - msg1.publicationID == msg2.publicationID && - equality.equals(msg1.details, msg2.details) && - equality.equals(msg1.args, msg2.args) && - equality.equals(msg1.kwargs, msg2.kwargs); + msg1.publicationID == msg2.publicationID && + equality.equals(msg1.details, msg2.details) && + equality.equals(msg1.args, msg2.args) && + equality.equals(msg1.kwargs, msg2.kwargs); test("JSONSerializer", () async { var msg = Event(1, 1); diff --git a/test/interoptests/messages/subscribe_test.dart b/test/interoptests/messages/subscribe_test.dart index e53cf2c..8be6ef2 100644 --- a/test/interoptests/messages/subscribe_test.dart +++ b/test/interoptests/messages/subscribe_test.dart @@ -51,4 +51,4 @@ void main() { expect(isEqual(message, msg), true); }); }); -} \ No newline at end of file +} diff --git a/test/interoptests/messages/subscribed_test.dart b/test/interoptests/messages/subscribed_test.dart index b8e45ea..8d7f92c 100644 --- a/test/interoptests/messages/subscribed_test.dart +++ b/test/interoptests/messages/subscribed_test.dart @@ -48,4 +48,4 @@ void main() { expect(isEqual(message, msg), true); }); }); -} \ No newline at end of file +} diff --git a/test/interoptests/messages/unsubscribed_test.dart b/test/interoptests/messages/unsubscribed_test.dart new file mode 100644 index 0000000..5c057c6 --- /dev/null +++ b/test/interoptests/messages/unsubscribed_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() { + group("Unsubscribed", () { + const baseSubCommand = "message unsubscribed 1"; + + bool isEqual(UnSubscribed msg1, UnSubscribed msg2) => msg1.requestID == msg2.requestID; + + test("JSONSerializer", () async { + var msg = UnSubscribed(1); + var command = "$baseSubCommand --serializer json"; + + var output = await runCommand(command); + + var jsonSerializer = JSONSerializer(); + var message = jsonSerializer.deserialize(output) as UnSubscribed; + expect(isEqual(message, msg), true); + }); + + test("CBORSerializer", () async { + var msg = UnSubscribed(1); + var command = "$baseSubCommand --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 UnSubscribed; + expect(isEqual(message, msg), true); + }); + + test("MsgPackSerializer", () async { + var msg = UnSubscribed(1); + var command = "$baseSubCommand --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 UnSubscribed; + expect(isEqual(message, msg), true); + }); + }); +}