]> git.stg.codes - stg.git/blob - tests/test_reconnect_on_tariff_change.cpp
e60e59890c10c22ad9d2c1b6d84b15846b4d810c
[stg.git] / tests / test_reconnect_on_tariff_change.cpp
1 #include "tut/tut.hpp"
2
3 #include "stg/user_property.h"
4 #include "user_impl.h"
5
6 #include "testsettings.h"
7 #include "testtariffs.h"
8 #include "testadmin.h"
9 #include "teststore.h"
10
11 namespace tut
12 {
13     struct reconnect_on_tariff_change_data {
14     };
15
16     typedef test_group<reconnect_on_tariff_change_data> tg;
17     tg reconnect_on_tariff_change_test_group("Reconnect on tariff change tests group");
18
19     typedef tg::object testobject;
20
21     class TEST_SETTINGS_LOCAL : public TEST_SETTINGS {
22         public:
23             TEST_SETTINGS_LOCAL(bool _reconnectOnTariffChange)
24                 : reconnectOnTariffChange(_reconnectOnTariffChange)
25             {}
26
27             bool GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
28
29         private:
30             bool reconnectOnTariffChange;
31     };
32
33     template<>
34     template<>
35     void testobject::test<1>()
36     {
37         set_test_name("Check normal behaviour");
38
39         TEST_SETTINGS_LOCAL settings(false);
40         TEST_TARIFFS tariffs;
41         TEST_ADMIN admin;
42         TEST_STORE store;
43         USER_IMPL user(&settings, &store, &tariffs, &admin, NULL);
44
45         USER_PROPERTY<std::string> & tariffName(user.GetProperty().tariffName);
46
47         ensure_equals("user.tariffName == NO_TARIFF_NAME", user.GetProperty().tariffName.ConstData(), NO_TARIFF_NAME);
48         tariffName = "test";
49         ensure_equals("user.tariffName == 'test'", user.GetProperty().tariffName.ConstData(), "test");
50     }
51 }