1 #define BOOST_TEST_MODULE STGTariff
3 #include "stg/tariff_conf.h"
4 #include "tariff_impl.h"
6 #pragma GCC diagnostic push
7 #pragma GCC diagnostic ignored "-Wold-style-cast"
8 #pragma GCC diagnostic ignored "-Wunused-parameter"
9 #pragma GCC diagnostic ignored "-Wsign-compare"
10 #pragma GCC diagnostic ignored "-Wparentheses"
11 #include <boost/test/unit_test.hpp>
12 #pragma GCC diagnostic pop
14 BOOST_AUTO_TEST_SUITE(Tariffs)
16 BOOST_AUTO_TEST_CASE(Construction)
18 STG::TariffData td("test");
19 td.tariffConf.fee = 1;
20 td.tariffConf.free = 2;
21 td.tariffConf.traffType = STG::Tariff::TRAFF_UP_DOWN;
22 td.tariffConf.passiveCost = 4;
23 td.dirPrice[0].mDay = 30;
24 td.dirPrice[0].hDay = 9;
25 td.dirPrice[0].mNight = 30;
26 td.dirPrice[0].hNight = 21;
27 td.dirPrice[0].priceDayA = 0;
28 td.dirPrice[0].priceDayB = 1;
29 td.dirPrice[0].priceNightA = 2;
30 td.dirPrice[0].priceNightB = 3;
31 td.dirPrice[0].threshold = 4;
32 td.dirPrice[0].singlePrice = 0;
33 td.dirPrice[0].noDiscount = 0;
34 const STG::TariffImpl tariff(td);
36 BOOST_CHECK(tariff.GetFreeMb() == td.tariffConf.free);
37 BOOST_CHECK(tariff.GetPassiveCost() == td.tariffConf.passiveCost);
38 BOOST_CHECK(tariff.GetFee() == td.tariffConf.fee);
39 BOOST_CHECK(tariff.GetFree() == td.tariffConf.free);
40 BOOST_CHECK(tariff.GetName() == td.tariffConf.name);
41 BOOST_CHECK(tariff.GetTraffType() == td.tariffConf.traffType);
42 BOOST_CHECK(tariff.GetThreshold(0) == td.dirPrice[0].threshold);
43 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
44 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 6);
45 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 6);
46 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 6);
47 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 6);
48 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 6);
49 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
52 BOOST_AUTO_TEST_CASE(TraffTypes)
54 STG::TariffData td("test");
55 td.tariffConf.fee = 1;
56 td.tariffConf.free = 2;
57 td.tariffConf.traffType = STG::Tariff::TRAFF_UP;
58 td.tariffConf.passiveCost = 4;
59 td.dirPrice[0].mDay = 30;
60 td.dirPrice[0].hDay = 9;
61 td.dirPrice[0].mNight = 30;
62 td.dirPrice[0].hNight = 21;
63 td.dirPrice[0].priceDayA = 0;
64 td.dirPrice[0].priceDayB = 1;
65 td.dirPrice[0].priceNightA = 2;
66 td.dirPrice[0].priceNightB = 3;
67 td.dirPrice[0].threshold = 4;
68 td.dirPrice[0].singlePrice = 0;
69 td.dirPrice[0].noDiscount = 0;
70 STG::TariffImpl tariff(td);
72 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_UP);
73 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
74 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 5);
75 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 4);
76 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 3);
77 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 2);
78 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 1);
79 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 0);
81 td.tariffConf.traffType = STG::Tariff::TRAFF_DOWN;
84 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_DOWN);
85 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 0);
86 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 1);
87 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 2);
88 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 3);
89 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 4);
90 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 5);
91 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
93 td.tariffConf.traffType = STG::Tariff::TRAFF_MAX;
96 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_MAX);
97 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
98 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 5);
99 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 4);
100 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 3);
101 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 4);
102 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 5);
103 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
105 td.tariffConf.traffType = STG::Tariff::TRAFF_UP_DOWN;
108 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_UP_DOWN);
109 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
110 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 6);
111 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 6);
112 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 6);
113 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 6);
114 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 6);
115 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
118 BOOST_AUTO_TEST_CASE(NormalIntervalPrices)
120 STG::TariffData td("test");
121 td.tariffConf.fee = 1;
122 td.tariffConf.free = 2;
123 td.tariffConf.traffType = STG::Tariff::TRAFF_UP_DOWN;
124 td.tariffConf.passiveCost = 4;
125 td.dirPrice[0].mDay = 30;
126 td.dirPrice[0].hDay = 9;
127 td.dirPrice[0].mNight = 30;
128 td.dirPrice[0].hNight = 21;
129 td.dirPrice[0].priceDayA = 0;
130 td.dirPrice[0].priceDayB = 1;
131 td.dirPrice[0].priceNightA = 2;
132 td.dirPrice[0].priceNightB = 3;
133 td.dirPrice[0].threshold = 4;
134 td.dirPrice[0].singlePrice = 0;
135 td.dirPrice[0].noDiscount = 0;
136 STG::TariffImpl tariff(td);
138 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
139 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 1); // Near 17:30, 6 > 4 DB
140 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 2); // Near 22:30, 0 < 4 NA
141 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 3); // Near 22:30, 6 > 4 NB
143 td.dirPrice[0].singlePrice = 1;
146 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
147 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 1); // Near 17:30, 6 > 4 DB
148 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
149 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB
151 td.dirPrice[0].singlePrice = 0;
152 td.dirPrice[0].noDiscount = 1;
155 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
156 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 6 > 4 DA
157 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 2); // Near 22:30, 0 < 4 NA
158 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 2); // Near 22:30, 6 > 4 NA
160 td.dirPrice[0].singlePrice = 1;
161 td.dirPrice[0].noDiscount = 1;
164 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
165 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 6 > 4 DA
166 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
167 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA
170 BOOST_AUTO_TEST_CASE(ConstructionForDayNightInversion)
172 STG::TariffData td("test");
173 td.tariffConf.fee = 1;
174 td.tariffConf.free = 2;
175 td.tariffConf.traffType = STG::Tariff::TRAFF_UP_DOWN;
176 td.tariffConf.passiveCost = 4;
177 td.dirPrice[0].mDay = 30;
178 td.dirPrice[0].hDay = 21;
179 td.dirPrice[0].mNight = 30;
180 td.dirPrice[0].hNight = 9;
181 td.dirPrice[0].priceDayA = 0;
182 td.dirPrice[0].priceDayB = 1;
183 td.dirPrice[0].priceNightA = 2;
184 td.dirPrice[0].priceNightB = 3;
185 td.dirPrice[0].threshold = 4;
186 td.dirPrice[0].singlePrice = 0;
187 td.dirPrice[0].noDiscount = 0;
188 const STG::TariffImpl tariff(td);
190 BOOST_CHECK(tariff.GetFreeMb() == td.tariffConf.free);
191 BOOST_CHECK(tariff.GetPassiveCost() == td.tariffConf.passiveCost);
192 BOOST_CHECK(tariff.GetFee() == td.tariffConf.fee);
193 BOOST_CHECK(tariff.GetFree() == td.tariffConf.free);
194 BOOST_CHECK(tariff.GetName() == td.tariffConf.name);
195 BOOST_CHECK(tariff.GetTraffType() == td.tariffConf.traffType);
196 BOOST_CHECK(tariff.GetThreshold(0) == td.dirPrice[0].threshold);
197 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
198 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 6);
199 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 6);
200 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 6);
201 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 6);
202 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 6);
203 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
206 BOOST_AUTO_TEST_CASE(TraffTypeForDayNightInversion)
208 STG::TariffData td("test");
209 td.tariffConf.fee = 1;
210 td.tariffConf.free = 2;
211 td.tariffConf.traffType = STG::Tariff::TRAFF_UP;
212 td.tariffConf.passiveCost = 4;
213 td.dirPrice[0].mDay = 30;
214 td.dirPrice[0].hDay = 21;
215 td.dirPrice[0].mNight = 30;
216 td.dirPrice[0].hNight = 9;
217 td.dirPrice[0].priceDayA = 0;
218 td.dirPrice[0].priceDayB = 1;
219 td.dirPrice[0].priceNightA = 2;
220 td.dirPrice[0].priceNightB = 3;
221 td.dirPrice[0].threshold = 4;
222 td.dirPrice[0].singlePrice = 0;
223 td.dirPrice[0].noDiscount = 0;
224 STG::TariffImpl tariff(td);
226 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_UP);
227 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
228 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 5);
229 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 4);
230 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 3);
231 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 2);
232 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 1);
233 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 0);
235 td.tariffConf.traffType = STG::Tariff::TRAFF_DOWN;
238 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_DOWN);
239 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 0);
240 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 1);
241 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 2);
242 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 3);
243 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 4);
244 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 5);
245 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
247 td.tariffConf.traffType = STG::Tariff::TRAFF_MAX;
250 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_MAX);
251 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
252 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 5);
253 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 4);
254 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 3);
255 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 4);
256 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 5);
257 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
259 td.tariffConf.traffType = STG::Tariff::TRAFF_UP_DOWN;
262 BOOST_CHECK(tariff.GetTraffType() == STG::Tariff::TRAFF_UP_DOWN);
263 BOOST_CHECK_EQUAL(tariff.GetTraffByType(6, 0), 6);
264 BOOST_CHECK_EQUAL(tariff.GetTraffByType(5, 1), 6);
265 BOOST_CHECK_EQUAL(tariff.GetTraffByType(4, 2), 6);
266 BOOST_CHECK_EQUAL(tariff.GetTraffByType(3, 3), 6);
267 BOOST_CHECK_EQUAL(tariff.GetTraffByType(2, 4), 6);
268 BOOST_CHECK_EQUAL(tariff.GetTraffByType(1, 5), 6);
269 BOOST_CHECK_EQUAL(tariff.GetTraffByType(0, 6), 6);
272 BOOST_AUTO_TEST_CASE(NormalIntervalPricesForDayNightInversion)
274 STG::TariffData td("test");
275 td.tariffConf.fee = 1;
276 td.tariffConf.free = 2;
277 td.tariffConf.traffType = STG::Tariff::TRAFF_UP_DOWN;
278 td.tariffConf.passiveCost = 4;
279 td.dirPrice[0].mDay = 30;
280 td.dirPrice[0].hDay = 21;
281 td.dirPrice[0].mNight = 30;
282 td.dirPrice[0].hNight = 9;
283 td.dirPrice[0].priceDayA = 0;
284 td.dirPrice[0].priceDayB = 1;
285 td.dirPrice[0].priceNightA = 2;
286 td.dirPrice[0].priceNightB = 3;
287 td.dirPrice[0].threshold = 4;
288 td.dirPrice[0].singlePrice = 0;
289 td.dirPrice[0].noDiscount = 0;
290 STG::TariffImpl tariff(td);
292 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 0 < 4 NA
293 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 3); // Near 17:30, 6 > 4 NB
294 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
295 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB
297 td.dirPrice[0].singlePrice = 1;
300 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA (ignore night)
301 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 1); // Near 17:30, 6 > 4 DB (ignore night)
302 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA (ignore night)
303 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB (ignore night)
305 td.dirPrice[0].singlePrice = 0;
306 td.dirPrice[0].noDiscount = 1;
309 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 0 < 4 NA
310 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 6 > 4 NA
311 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
312 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA
314 td.dirPrice[0].singlePrice = 1;
315 td.dirPrice[0].noDiscount = 1;
318 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA (ignore night)
319 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 6 > 4 DA (ignore night)
320 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA (ignore night)
321 BOOST_CHECK_EQUAL(tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA (ignore night)
324 BOOST_AUTO_TEST_CASE(ChangePolicyAllow)
326 STG::TariffData td("test");
327 td.tariffConf.changePolicy = STG::Tariff::ALLOW;
328 td.tariffConf.fee = 100;
329 const STG::TariffImpl tariff(td);
331 td.tariffConf.fee = 50;
332 const STG::TariffImpl cheaper(td);
334 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(cheaper, 1461606400).empty(), true);
336 td.tariffConf.fee = 100;
337 const STG::TariffImpl equal(td);
339 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(equal, 1461606400).empty(), true);
341 td.tariffConf.fee = 150;
342 const STG::TariffImpl expensive(td);
344 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(expensive, 1461606400).empty(), true);
347 BOOST_AUTO_TEST_CASE(ChangePolicyToCheap)
349 STG::TariffData td("test");
350 td.tariffConf.changePolicy = STG::Tariff::TO_CHEAP;
351 td.tariffConf.fee = 100;
352 const STG::TariffImpl tariff(td);
354 td.tariffConf.fee = 50;
355 const STG::TariffImpl cheaper(td);
357 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(cheaper, 1461606400).empty(), true);
359 td.tariffConf.fee = 100;
360 const STG::TariffImpl equal(td);
362 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(equal, 1461606400).empty(), false);
364 td.tariffConf.fee = 150;
365 const STG::TariffImpl expensive(td);
367 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(expensive, 1461606400).empty(), false);
370 BOOST_AUTO_TEST_CASE(ChangePolicyToExpensive)
372 STG::TariffData td("test");
373 td.tariffConf.changePolicy = STG::Tariff::TO_EXPENSIVE;
374 td.tariffConf.fee = 100;
375 const STG::TariffImpl tariff(td);
377 td.tariffConf.fee = 50;
378 const STG::TariffImpl cheaper(td);
380 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(cheaper, 1461606400).empty(), false);
382 td.tariffConf.fee = 100;
383 const STG::TariffImpl equal(td);
385 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(equal, 1461606400).empty(), true);
387 td.tariffConf.fee = 150;
388 const STG::TariffImpl expensive(td);
390 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(expensive, 1461606400).empty(), true);
393 BOOST_AUTO_TEST_CASE(ChangePolicyDeny)
395 STG::TariffData td("test");
396 td.tariffConf.changePolicy = STG::Tariff::DENY;
397 td.tariffConf.fee = 100;
398 const STG::TariffImpl tariff(td);
400 td.tariffConf.fee = 50;
401 const STG::TariffImpl cheaper(td);
403 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(cheaper, 1461606400).empty(), false);
405 td.tariffConf.fee = 100;
406 const STG::TariffImpl equal(td);
408 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(equal, 1461606400).empty(), false);
410 td.tariffConf.fee = 150;
411 const STG::TariffImpl expensive(td);
413 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(expensive, 1461606400).empty(), false);
416 BOOST_AUTO_TEST_CASE(ChangePolicyTimeoutInThePast)
418 STG::TariffData td("test");
419 td.tariffConf.changePolicyTimeout = 1451606400;
420 td.tariffConf.changePolicy = STG::Tariff::TO_EXPENSIVE;
421 td.tariffConf.fee = 100;
422 const STG::TariffImpl tariff(td);
424 td.tariffConf.fee = 50;
425 const STG::TariffImpl cheaper(td);
427 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(cheaper, 1461606400).empty(), true);
430 BOOST_AUTO_TEST_CASE(ChangePolicyTimeoutInFuture)
432 STG::TariffData td("test");
433 td.tariffConf.changePolicyTimeout = 1483228800;
434 td.tariffConf.changePolicy = STG::Tariff::TO_EXPENSIVE;
435 td.tariffConf.fee = 100;
436 const STG::TariffImpl tariff(td);
438 td.tariffConf.fee = 50;
439 const STG::TariffImpl cheaper(td);
441 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(cheaper, 1461606400).empty(), false);
444 BOOST_AUTO_TEST_CASE(ChangePolicyTimeoutNow)
446 STG::TariffData td("test");
447 td.tariffConf.changePolicyTimeout = 0;
448 td.tariffConf.changePolicy = STG::Tariff::TO_EXPENSIVE;
449 td.tariffConf.fee = 100;
450 const STG::TariffImpl tariff(td);
452 td.tariffConf.fee = 50;
453 const STG::TariffImpl cheaper(td);
455 BOOST_CHECK_EQUAL(tariff.TariffChangeIsAllowed(cheaper, 1461606400).empty(), false);
458 BOOST_AUTO_TEST_SUITE_END()