refactoring test/test_Message.hpp

master
Denes Matetelki 12 years ago
parent ef2a90f17f
commit 6bc4ddc488

@ -5,66 +5,69 @@
#include "Message.hpp" #include "Message.hpp"
#include "Connection.hpp" #include "Connection.hpp"
class TestMessage : public CxxTest::TestSuite
class SimpleMessage : public Message
{ {
private: public:
class SimpleMessage : public Message SimpleMessage( void *msgParam = 0)
: Message(msgParam)
{ {
public: TRACE;
}
SimpleMessage( void *msgParam = 0) bool buildMessage( const void *msgPart,
: Message(msgParam) const size_t msgLen )
{ {
TRACE; TRACE;
} m_buffer = std::string( (const char*) msgPart, msgLen );
onMessageReady();
return true;
}
bool buildMessage( const void *msgPart, void onMessageReady()
const size_t msgLen ) {
{ TRACE;
TRACE;
m_buffer = std::string( (const char*) msgPart, msgLen );
onMessageReady();
return true;
}
void onMessageReady() LOG_BEGIN(Logger::INFO)
{ LOG_PROP("message", m_buffer)
TRACE; LOG_END("Got reply from server.");
LOG_BEGIN(Logger::INFO) *( static_cast<bool*>(m_param) ) = true;
LOG_PROP("message", m_buffer)
LOG_END("Got reply from server.");
*( static_cast<bool*>(m_param) ) = true; if (m_connection != 0)
m_connection->send(m_buffer.c_str(), m_buffer.length());
if (m_connection != 0) m_buffer.clear();
m_connection->send(m_buffer.c_str(), m_buffer.length()); }
}
Message* clone() Message* clone()
{ {
TRACE; TRACE;
return new SimpleMessage(m_param); return new SimpleMessage(m_param);
} }
std::string getBuffer() std::string getBuffer()
{ {
TRACE; TRACE;
return m_buffer; return m_buffer;
} }
protected: protected:
size_t getExpectedLength() size_t getExpectedLength()
{ {
TRACE; TRACE;
return 0; return 0;
} }
}; // SimpleMessage }; // SimpleMessage
class TestMessage : public CxxTest::TestSuite
{
private:
class DummyConnection : public Connection class DummyConnection : public Connection
{ {
public: public:

Loading…
Cancel
Save