[Boost.Test + Turtle] Suggestion how to test async events.
Hi,
I'm trying to take a first touch with Boost.Test and Turtle.
I have some objects for network communication with async notifications.
class ServerHandler : public MessageEventHandler
{
public:
ServerHandler() {
// Register the messages I want to manage
this->RegisterMsg(E_MSG_METHOD_CONNECT,
Poco::delegate(this, &ServerHandler::OnMsgMethodConnect));
}
// Messages Handlers
virtual void OnMsgMethodConnect(const void* pSender, TArgs& args) {
cout << "ServerHandler receive E_MSG_METHOD_CONNECT" << endl;
MSG_METHOD_CONNECT& msg =
RetrieveMessage
On 08/04/2013 16:32, Daniele Barzotti wrote:
(...)
Now, I have to test if into the ServerHandler::OnMsgMethodConnect() the argument args.msg (which is a message class) has the correct values.
EG. if (msg.station_type() == EStationType::ST_CLIENT) => OK
Which is the correct way to do it?
Regards, Daniele.
Hi Daniele, Turtle is not a boost component, so you might want to create a ticket for support directly to the project (see http://sourceforge.net/projects/turtle/support/). A 'with' takes a constraint which general form is a functor testing the received argument (see http://turtle.sourceforge.net/turtle/customisation.html#turtle.customisation...). The simplest solution for your problem would be a free function : bool CheckArgs( TArgs& args ) { return args.msg.station_type() == EStationType::ST_CLIENT; } with the expectation being : MOCK_EXPECT( mockSvr.OnMsgMethodConnect ).once().with( mock::any, &CheckArgs ); Of course this will quickly become tedious if you write several tests checking various values, and you might want to factorize things a bit. If you need more information, just create a support ticket and I will be happy to help ! Cheers, MAT.
On 08/04/2013 18:43, Mathieu Champlon wrote:
Hi Daniele,
Turtle is not a boost component, so you might want to create a ticket for support directly to the project (see http://sourceforge.net/projects/turtle/support/). (...) If you need more information, just create a support ticket and I will be happy to help !
Cheers, MAT.
Hi Mat! Thanks a lot for your reply! I'm sorry to have posted here, I supposed the ticket system was only for bugs :-) Thanks for your suggestion! I will open a ticket in the support page! Cheers, Daniele.
participants (2)
-
Daniele Barzotti
-
Mathieu Champlon