+ template<>
+ template<>
+ void testobject::test<2>()
+ {
+ set_test_name("Check second rules (allow fee if cash value is positive)");
+
+ TEST_SETTINGS_LOCAL settings(1);
+ TEST_TARIFFS tariffs;
+ STG::Admin admin(STG::Priv(0xFFFF), {}, {});
+ TEST_STORE store;
+ TEST_SERVICES services;
+ STG::UserImpl user(&settings, &store, &tariffs, &admin, NULL, services);
+
+ STG::UserProperty<double> & cash(user.GetProperties().cash);
+ STG::UserProperty<double> & credit(user.GetProperties().credit);
+ STG::UserProperty<std::string> & tariffName(user.GetProperties().tariffName);
+
+ ensure_equals("user.cash == 0 (initial value)", user.GetProperties().cash, 0);
+ ensure_equals("user.credit == 0 (initial value)", user.GetProperties().credit, 0);
+ cash = 100;
+ ensure_equals("user.cash == 100 (explicitly set)", user.GetProperties().cash, 100);
+
+ tariffs.SetFee(50);
+ tariffName = "test";
+ ensure_equals("user.tariffName == 'test' (explicitly set)", user.GetProperties().tariffName.ConstData(), "test");
+ user.ProcessDayFee();
+ ensure_equals("user.cash == 50 (first fee charge)", user.GetProperties().cash, 50);
+ user.ProcessDayFee();
+ ensure_equals("user.cash == 0 (second fee charge)", user.GetProperties().cash, 0);
+ user.ProcessDayFee();
+ ensure_equals("user.cash == -50 (third fee charge)", user.GetProperties().cash, -50);
+ user.ProcessDayFee();
+ ensure_equals("user.cash == -50 (not charging `cause value is negative)", user.GetProperties().cash, -50);
+ cash = 49;
+ ensure_equals("user.cash == 49 (explicitly set)", user.GetProperties().cash, 49);
+ user.ProcessDayFee();
+ ensure_equals("user.cash == -1 (charge to negative value)", user.GetProperties().cash, -1);
+ user.ProcessDayFee();
+ ensure_equals("user.cash == -1 (not charging `cause value is negative)", user.GetProperties().cash, -1);
+ credit = 50;
+ ensure_equals("user.credit == 50 (explicitly set)", user.GetProperties().credit, 50);
+ user.ProcessDayFee();
+ ensure_equals("user.cash == -51 (charging `cause value + credit gives us a positive value)", user.GetProperties().cash, -51);
+ user.ProcessDayFee();
+ ensure_equals("user.cash == -51 (not charging `cause credit now is not enoght)", user.GetProperties().cash, -51);
+ }