⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multicastertest.h

📁 著名的uncle Bob的Agile software development的代码
💻 H
字号:


#ifndef MULTICASTERTEST_H
#define MULTICASTERTEST_H

#include "Multicaster.h"

#ifndef CPPUNIT_TESTCASE_H
#include "TestCase.h"
#endif





class MulticasterTest : public TestCase
{
public:
    class Observer : public MulticastObserver
    {
    public:
        int             m_state;
        std::string     m_lastAddressReceived;

                        Observer () : m_state (0) {}
                        Observer (std::string initialAddress, int state) 
                            : m_lastAddressReceived (initialAddress), m_state (state) {}

        virtual void    accept (std::string address, Value Value)
        { m_lastAddressReceived = address; m_state++; }

    };

    Multicaster                 *m_multicaster;
    Observer                    *m_o1;
    Observer                    *m_o2;
    Observer                    *m_o3;
    Observer                    *m_o4;


protected:
    void                        setUp ();
    void                        tearDown ();

    void                        testSinglePublish ();
    void                        testMultipleHomogenousPublish ();
    void                        testMultipleHeterogenousPublish ();
    void                        testSingleUnsubscribe ();
    void                        testMultipleUnsubscribe ();
    void                        testSimpleUnsubscribeAll ();
    void                        testComplexUnsubscribeAll ();

public:
                                MulticasterTest (std::string name);
    virtual                     ~MulticasterTest ();

    static Test                 *suite ();

};


inline bool operator== (const MulticasterTest::Observer& o1, const MulticasterTest::Observer& o2)
{ return o1.m_state == o2.m_state && o1.m_lastAddressReceived == o2.m_lastAddressReceived; }


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -