From 6bc4ddc4880b3e0a7712830a408c8228d1ff64a7 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Fri, 5 Jul 2013 20:02:01 +0200 Subject: [PATCH] refactoring test/test_Message.hpp --- test/test_Message.hpp | 91 ++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/test/test_Message.hpp b/test/test_Message.hpp index de58972..460fb69 100644 --- a/test/test_Message.hpp +++ b/test/test_Message.hpp @@ -5,66 +5,69 @@ #include "Message.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) - : Message(msgParam) - { - TRACE; - } + bool buildMessage( const void *msgPart, + const size_t msgLen ) + { + TRACE; + m_buffer = std::string( (const char*) msgPart, msgLen ); + onMessageReady(); + return true; + } - bool buildMessage( const void *msgPart, - const size_t msgLen ) - { - TRACE; - m_buffer = std::string( (const char*) msgPart, msgLen ); - onMessageReady(); - return true; - } + void onMessageReady() + { + TRACE; - void onMessageReady() - { - TRACE; + LOG_BEGIN(Logger::INFO) + LOG_PROP("message", m_buffer) + LOG_END("Got reply from server."); - LOG_BEGIN(Logger::INFO) - LOG_PROP("message", m_buffer) - LOG_END("Got reply from server."); + *( static_cast(m_param) ) = true; - *( static_cast(m_param) ) = true; + if (m_connection != 0) + m_connection->send(m_buffer.c_str(), m_buffer.length()); - if (m_connection != 0) - m_connection->send(m_buffer.c_str(), m_buffer.length()); - } + m_buffer.clear(); + } - Message* clone() - { - TRACE; - return new SimpleMessage(m_param); - } + Message* clone() + { + TRACE; + return new SimpleMessage(m_param); + } - std::string getBuffer() - { - TRACE; - return m_buffer; - } + std::string getBuffer() + { + TRACE; + return m_buffer; + } - protected: +protected: - size_t getExpectedLength() - { - TRACE; - return 0; - } + size_t getExpectedLength() + { + TRACE; + return 0; + } - }; // SimpleMessage +}; // SimpleMessage +class TestMessage : public CxxTest::TestSuite +{ +private: + class DummyConnection : public Connection { public: