From: Maxim Mamontov Date: Thu, 26 May 2011 16:13:59 +0000 (+0300) Subject: Connection notifier and watcher added X-Git-Tag: 2.408-alpha~126 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/6c3c5273f14dc61690fed0cb5a825c46bbf08b62?ds=sidebyside;hp=2d09f6a7afb3481586a9471b0cde35aac271ce9d Connection notifier and watcher added --- diff --git a/tests/test_reconnect_on_tariff_change.cpp b/tests/test_reconnect_on_tariff_change.cpp index e60e5989..a5f1ce73 100644 --- a/tests/test_reconnect_on_tariff_change.cpp +++ b/tests/test_reconnect_on_tariff_change.cpp @@ -8,6 +8,23 @@ #include "testadmin.h" #include "teststore.h" +class AFTER_CONNECTED_NOTIFIER : public PROPERTY_NOTIFIER_BASE, + private NONCOPYABLE { +public: + AFTER_CONNECTED_NOTIFIER() + : connects(0), + disconnects(0) + {} + void Notify(const bool & oldValue, const bool & newValue); + + size_t GetConnects() const { return connects; } + size_t GetDisconnects() const { return disconnects; } + +private: + size_t connects; + size_t disconnects; +}; + namespace tut { struct reconnect_on_tariff_change_data { @@ -42,10 +59,25 @@ namespace tut TEST_STORE store; USER_IMPL user(&settings, &store, &tariffs, &admin, NULL); + AFTER_CONNECTED_NOTIFIER connectionNotifier; + + user.AddConnectedAfterNotifier(&connectionNotifier); + USER_PROPERTY & tariffName(user.GetProperty().tariffName); + ensure_equals("connects = 0", connectionNotifier.GetConnects(), 0); + ensure_equals("disconnects = 0", connectionNotifier.GetDisconnects(), 0); + ensure_equals("user.tariffName == NO_TARIFF_NAME", user.GetProperty().tariffName.ConstData(), NO_TARIFF_NAME); tariffName = "test"; ensure_equals("user.tariffName == 'test'", user.GetProperty().tariffName.ConstData(), "test"); } } + +void AFTER_CONNECTED_NOTIFIER::Notify(const bool & oldValue, const bool & newValue) +{ + if (!oldValue && newValue) + ++connects; + if (oldValue && !newValue) + ++disconnects; +}