]> git.stg.codes - stg.git/commitdiff
Added unit-test for ReconnectOnTariffChange property
authorMaxim Mamontov <faust@gts.dp.ua>
Thu, 26 May 2011 15:46:30 +0000 (18:46 +0300)
committerMaxim Mamontov <faust@gts.dp.ua>
Thu, 26 May 2011 15:46:30 +0000 (18:46 +0300)
tests/Makefile
tests/test_reconnect_on_tariff_change.cpp [new file with mode: 0644]

index 43643cacffe24e1e21607839074ae14450defe7b..ac6e4e10158433e2b0984b3674820566f38b8d3b 100644 (file)
@@ -8,6 +8,7 @@ SOURCES=main.cpp \
        test_tariff.cpp \
        test_conffiles.cpp \
        test_fee_charge_rules.cpp \
        test_tariff.cpp \
        test_conffiles.cpp \
        test_fee_charge_rules.cpp \
+       test_reconnect_on_tariff_change.cpp \
        ../projects/stargazer/tariff_impl.cpp \
        ../projects/stargazer/user_impl.cpp \
        ../projects/stargazer/user_property.cpp \
        ../projects/stargazer/tariff_impl.cpp \
        ../projects/stargazer/user_impl.cpp \
        ../projects/stargazer/user_property.cpp \
diff --git a/tests/test_reconnect_on_tariff_change.cpp b/tests/test_reconnect_on_tariff_change.cpp
new file mode 100644 (file)
index 0000000..e60e598
--- /dev/null
@@ -0,0 +1,51 @@
+#include "tut/tut.hpp"
+
+#include "stg/user_property.h"
+#include "user_impl.h"
+
+#include "testsettings.h"
+#include "testtariffs.h"
+#include "testadmin.h"
+#include "teststore.h"
+
+namespace tut
+{
+    struct reconnect_on_tariff_change_data {
+    };
+
+    typedef test_group<reconnect_on_tariff_change_data> tg;
+    tg reconnect_on_tariff_change_test_group("Reconnect on tariff change tests group");
+
+    typedef tg::object testobject;
+
+    class TEST_SETTINGS_LOCAL : public TEST_SETTINGS {
+        public:
+            TEST_SETTINGS_LOCAL(bool _reconnectOnTariffChange)
+                : reconnectOnTariffChange(_reconnectOnTariffChange)
+            {}
+
+            bool GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
+
+        private:
+            bool reconnectOnTariffChange;
+    };
+
+    template<>
+    template<>
+    void testobject::test<1>()
+    {
+        set_test_name("Check normal behaviour");
+
+        TEST_SETTINGS_LOCAL settings(false);
+        TEST_TARIFFS tariffs;
+        TEST_ADMIN admin;
+        TEST_STORE store;
+        USER_IMPL user(&settings, &store, &tariffs, &admin, NULL);
+
+        USER_PROPERTY<std::string> & tariffName(user.GetProperty().tariffName);
+
+        ensure_equals("user.tariffName == NO_TARIFF_NAME", user.GetProperty().tariffName.ConstData(), NO_TARIFF_NAME);
+        tariffName = "test";
+        ensure_equals("user.tariffName == 'test'", user.GetProperty().tariffName.ConstData(), "test");
+    }
+}