3 #include "stg/user_property.h"
6 #include "testsettings.h"
7 #include "testtariffs.h"
11 class AFTER_CONNECTED_NOTIFIER : public PROPERTY_NOTIFIER_BASE<bool>,
14 AFTER_CONNECTED_NOTIFIER()
18 void Notify(const bool & oldValue, const bool & newValue);
20 size_t GetConnects() const { return connects; }
21 size_t GetDisconnects() const { return disconnects; }
30 struct reconnect_on_tariff_change_data {
33 typedef test_group<reconnect_on_tariff_change_data> tg;
34 tg reconnect_on_tariff_change_test_group("Reconnect on tariff change tests group");
36 typedef tg::object testobject;
38 class TEST_SETTINGS_LOCAL : public TEST_SETTINGS {
40 TEST_SETTINGS_LOCAL(bool _reconnectOnTariffChange)
41 : reconnectOnTariffChange(_reconnectOnTariffChange)
44 bool GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
47 bool reconnectOnTariffChange;
52 void testobject::test<1>()
54 set_test_name("Check normal behaviour");
56 TEST_SETTINGS_LOCAL settings(false);
60 USER_IMPL user(&settings, &store, &tariffs, &admin, NULL);
62 AFTER_CONNECTED_NOTIFIER connectionNotifier;
64 user.AddConnectedAfterNotifier(&connectionNotifier);
66 USER_PROPERTY<std::string> & tariffName(user.GetProperty().tariffName);
68 ensure_equals("connects = 0", connectionNotifier.GetConnects(), 0);
69 ensure_equals("disconnects = 0", connectionNotifier.GetDisconnects(), 0);
71 ensure_equals("user.tariffName == NO_TARIFF_NAME", user.GetProperty().tariffName.ConstData(), NO_TARIFF_NAME);
73 ensure_equals("user.tariffName == 'test'", user.GetProperty().tariffName.ConstData(), "test");
77 void AFTER_CONNECTED_NOTIFIER::Notify(const bool & oldValue, const bool & newValue)
79 if (!oldValue && newValue)
81 if (oldValue && !newValue)