-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from muzzammilshahid/refactor-call-message-test
Refactor interoperability test for call message
- Loading branch information
Showing
2 changed files
with
58 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import "package:collection/collection.dart"; | ||
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("Call", () { | ||
const equality = DeepCollectionEquality(); | ||
const testProcedure = "io.xconn.test"; | ||
|
||
bool isEqual(Call msg1, Call msg2) => | ||
msg1.requestID == msg2.requestID && | ||
msg1.uri == msg2.uri && | ||
equality.equals(msg1.options, msg2.options) && | ||
equality.equals(msg1.args, msg2.args) && | ||
equality.equals(msg1.kwargs, msg2.kwargs); | ||
|
||
test("JSONSerializer", () async { | ||
var callMessage = Call(1, testProcedure); | ||
var command = "message call ${callMessage.requestID} ${callMessage.uri} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as Call; | ||
expect(isEqual(message, callMessage), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var callMessage = Call(1, testProcedure, args: ["abc"]); | ||
var command = "message call ${callMessage.requestID} ${callMessage.uri} abc --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 Call; | ||
expect(isEqual(message, callMessage), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var callMessage = Call(1, testProcedure, args: ["abc"], kwargs: {"a": 1}); | ||
var command = | ||
"message call ${callMessage.requestID} ${callMessage.uri} abc -k a=1 --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 Call; | ||
expect(isEqual(message, callMessage), true); | ||
}); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.