Skip to content

Commit

Permalink
Add interoperabilty tests for UnRegistered message
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed Jul 2, 2024
1 parent 4aa3050 commit 2f99c62
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/interoptests/messages/invocation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void main() {

test("MsgPackSerializer", () async {
var msg = Invocation(1, 1, args: ["abc"], kwargs: {"a": 1});
var command = "message invocation ${msg.requestID} ${msg.registrationID} abc -k a=1 --serializer msgpack --output hex";
var command =
"message invocation ${msg.requestID} ${msg.registrationID} abc -k a=1 --serializer msgpack --output hex";

var output = await runCommand(command);
var outputBytes = Base16Encoder.instance.decode(output.trim());
Expand Down
48 changes: 48 additions & 0 deletions test/interoptests/messages/unregistered_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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("UnRegistered", () {
bool isEqual(UnRegistered msg1, UnRegistered msg2) => msg1.requestID == msg2.requestID;

test("JSONSerializer", () async {
var msg = UnRegistered(1);
var command = "message unregistered ${msg.requestID} --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 = "message unregistered ${msg.requestID} --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 = "message unregistered ${msg.requestID} --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);
});
});
}

0 comments on commit 2f99c62

Please sign in to comment.