]> git.stg.codes - stg.git/blob - tests/test_fee_charge_rules.cpp
Test TARIFFS implementation added
[stg.git] / tests / test_fee_charge_rules.cpp
1 #include "tut/tut.hpp"
2
3 #include "stg/settings.h"
4 #include "stg/user_property.h"
5 #include "user_impl.h"
6
7 const volatile time_t stgTime = 0;
8
9 namespace tut
10 {
11     struct fee_charge_rules_data {
12     };
13
14     typedef test_group<fee_charge_rules_data> tg;
15     tg fee_charge_rules_test_group("Fee charge rules tests group");
16
17     typedef tg::object testobject;
18
19     class TEST_SETTINGS : public SETTINGS {
20         public:
21             TEST_SETTINGS(unsigned _feeChargeType)
22                 : feeChargeType(_feeChargeType) {}
23
24             const std::string & GetDirName(size_t) const { return dirName; }
25             const std::string & GetScriptsDir() const { return scriptsDir; }
26             unsigned            GetDetailStatWritePeriod() const { return 10; }
27             unsigned            GetStatWritePeriod() const { return 10; }
28             unsigned            GetDayFee() const { return 0; }
29             bool                GetFullFee() const { return false; }
30             unsigned            GetDayResetTraff() const { return 0; }
31             bool                GetSpreadFee() const { return false; }
32             bool                GetFreeMbAllowInet() const { return false; }
33             bool                GetDayFeeIsLastDay() const { return false; }
34             bool                GetWriteFreeMbTraffCost() const { return false; }
35             bool                GetShowFeeInCash() const { return false; }
36             unsigned            GetMessageTimeout() const { return 0; }
37             unsigned            GetFeeChargeType() const { return feeChargeType; }
38             const std::string & GetMonitorDir() const { return monitorDir; }
39             bool                GetMonitoring() const { return false; }
40
41         private:
42             std::string dirName;
43             std::string scriptsDir;
44             std::string monitorDir;
45             unsigned feeChargeType;
46     };
47
48     class TEST_TARIFFS : public TARIFFS {
49         public:
50             TEST_TARIFFS() {}
51
52             int            ReadTariffs () { return 0; }
53             const TARIFF * FindByName(const std::string & name) const { return NULL; }
54             const TARIFF * GetNoTariff() const { return NULL; }
55             int            GetTariffsNum() const { return 0; }
56             int            Del(const std::string & name, const ADMIN * admin) { return 0; }
57             int            Add(const std::string & name, const ADMIN * admin) { return 0; }
58             int            Chg(const TARIFF_DATA & td, const ADMIN * admin) { return 0; }
59
60             void           GetTariffsData(std::list<TARIFF_DATA> * tdl) {}
61
62             const std::string & GetStrError() const { return strError; }
63
64         private:
65             std::string strError;
66     };
67
68     template<>
69     template<>
70     void testobject::test<1>()
71     {
72         set_test_name("Check classic rules");
73
74         TEST_SETTINGS settings(0);
75         TEST_TARIFFS tariffs;
76         USER_IMPL user(&settings, NULL, &tariffs, NULL, NULL);
77
78         USER_PROPERTY<double> & cash(user.GetProperty().cash);
79
80         ensure_equals("user.cash == 0", user.GetProperty().cash, 0);
81         cash = 100;
82         ensure_equals("user.cash == 0", user.GetProperty().cash, 100);
83     }
84 }