mirror of https://github.com/deavmi/doap
CoapClient (unit tests)
- Added a test for the message IDs
This commit is contained in:
parent
6c20adfe11
commit
9578ad029f
|
@ -317,6 +317,48 @@ version(unittest)
|
|||
import std.stdio : writeln;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client testing
|
||||
*
|
||||
* Tests the rolling of the message id
|
||||
*/
|
||||
unittest
|
||||
{
|
||||
CoapClient client = new CoapClient("coap.me", 5683);
|
||||
|
||||
|
||||
CoapRequestFuture future = client.newRequestBuilder()
|
||||
.payload(cast(ubyte[])"First message")
|
||||
.token([69])
|
||||
.post();
|
||||
|
||||
|
||||
writeln("Future start (first)");
|
||||
CoapPacket response = future.get();
|
||||
writeln("Future done (first)");
|
||||
writeln("Got response (first): ", response);
|
||||
assert(response.getMessageId() == 0);
|
||||
|
||||
future = client.newRequestBuilder()
|
||||
.payload(cast(ubyte[])"Second message")
|
||||
.token([69])
|
||||
.post();
|
||||
|
||||
|
||||
writeln("Future start (second)");
|
||||
response = future.get();
|
||||
writeln("Future done (second)");
|
||||
writeln("Got response (second): ", response);
|
||||
assert(response.getMessageId() == 1);
|
||||
|
||||
|
||||
|
||||
|
||||
client.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Client testing
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue