]> git.stg.codes - stg.git/blob - tests/test_fee_charge_rules.cpp
93b7dd6052fd33cfdd4deab78dab9262e9cb189b
[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     template<>
49     template<>
50     void testobject::test<1>()
51     {
52         set_test_name("Check classic rules");
53
54         TEST_SETTINGS settings(0);
55         USER_IMPL user(&settings, NULL, NULL, NULL, NULL);
56
57         USER_PROPERTY<double> & cash(user.GetProperty().cash);
58
59         ensure_equals("user.cash == 0", user.GetProperty().cash, 0);
60         cash = 100;
61         ensure_equals("user.cash == 0", user.GetProperty().cash, 100);
62     }
63 }