X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/9f3223722138dadc2f6cd54dfcbad3d19a3db4d6..6c3c5273f14dc61690fed0cb5a825c46bbf08b62:/tests/test_reconnect_on_tariff_change.cpp 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; +}