From: Maxim Mamontov Date: Sat, 31 Jan 2015 16:36:56 +0000 (+0200) Subject: Fixed tests. X-Git-Tag: 2.409~196 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/b35652569fcfeaa0ca1679dfb30648b008de61ed Fixed tests. --- diff --git a/include/stg/service_conf.h b/include/stg/service_conf.h index ca58154b..84f052a5 100644 --- a/include/stg/service_conf.h +++ b/include/stg/service_conf.h @@ -1,10 +1,31 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Author : Maxim Mamontov + */ + #ifndef SERVICE_CONF_H #define SERVICE_CONF_H -#include - +#include "resetable.h" #include "os_int.h" +#include + struct SERVICE_CONF { SERVICE_CONF() @@ -30,6 +51,51 @@ double cost; uint8_t payDay; }; +struct SERVICE_CONF_RES +{ +SERVICE_CONF_RES() + : name(), comment(), + cost(), payDay() +{} + +SERVICE_CONF_RES(const SERVICE_CONF & rhs) + : name(rhs.name), comment(rhs.comment), + cost(rhs.cost), payDay(rhs.payDay) +{} + +SERVICE_CONF_RES & operator=(const SERVICE_CONF & conf) +{ +name = conf.name; +comment = conf.comment; +cost = conf.cost; +payDay = conf.payDay; +return *this; +} + +SERVICE_CONF GetData() const +{ +SERVICE_CONF sc; +sc.name = name.data(); +sc.comment = comment.data(); +sc.cost = cost.data(); +sc.payDay = payDay.data(); +return sc; +} + +void Splice(const SERVICE_CONF_RES & rhs) +{ +name.splice(rhs.name); +comment.splice(rhs.comment); +cost.splice(rhs.cost); +payDay.splice(rhs.payDay); +} + +RESETABLE name; +RESETABLE comment; +RESETABLE cost; +RESETABLE payDay; +}; + inline bool operator==(const SERVICE_CONF & a, const SERVICE_CONF & b) { diff --git a/include/stg/services.h b/include/stg/services.h index ddec31be..140391d0 100644 --- a/include/stg/services.h +++ b/include/stg/services.h @@ -21,10 +21,10 @@ #ifndef SERVICES_H #define SERVICES_H -#include - #include "service_conf.h" +#include + class ADMIN; class SERVICES { @@ -33,7 +33,8 @@ public: virtual int Add(const SERVICE_CONF & service, const ADMIN * admin) = 0; virtual int Del(const std::string & name, const ADMIN * admin) = 0; virtual int Change(const SERVICE_CONF & service, const ADMIN * admin) = 0; - virtual bool Find(const std::string & name, SERVICE_CONF * service) = 0; + virtual bool Find(const std::string & name, SERVICE_CONF * service) const = 0; + virtual bool Find(const std::string & name, SERVICE_CONF_RES * service) const = 0; virtual bool Exists(const std::string & name) const = 0; virtual const std::string & GetStrError() const = 0; virtual size_t Count() const = 0; diff --git a/tests/test_fee_charge_rules.cpp b/tests/test_fee_charge_rules.cpp index 825c2b36..2df09be4 100644 --- a/tests/test_fee_charge_rules.cpp +++ b/tests/test_fee_charge_rules.cpp @@ -7,6 +7,7 @@ #include "testtariffs.h" #include "testadmin.h" #include "teststore.h" +#include "testservices.h" namespace tut { @@ -40,7 +41,8 @@ namespace tut TEST_TARIFFS tariffs; TEST_ADMIN admin; TEST_STORE store; - USER_IMPL user(&settings, &store, &tariffs, &admin, NULL); + TEST_SERVICES services; + USER_IMPL user(&settings, &store, &tariffs, &admin, NULL, services); USER_PROPERTY & cash(user.GetProperty().cash); USER_PROPERTY & tariffName(user.GetProperty().tariffName); @@ -72,7 +74,8 @@ namespace tut TEST_TARIFFS tariffs; TEST_ADMIN admin; TEST_STORE store; - USER_IMPL user(&settings, &store, &tariffs, &admin, NULL); + TEST_SERVICES services; + USER_IMPL user(&settings, &store, &tariffs, &admin, NULL, services); USER_PROPERTY & cash(user.GetProperty().cash); USER_PROPERTY & credit(user.GetProperty().credit); @@ -118,7 +121,8 @@ namespace tut TEST_TARIFFS tariffs; TEST_ADMIN admin; TEST_STORE store; - USER_IMPL user(&settings, &store, &tariffs, &admin, NULL); + TEST_SERVICES services; + USER_IMPL user(&settings, &store, &tariffs, &admin, NULL, services); USER_PROPERTY & cash(user.GetProperty().cash); USER_PROPERTY & credit(user.GetProperty().credit); diff --git a/tests/test_reconnect_on_tariff_change.cpp b/tests/test_reconnect_on_tariff_change.cpp index 8e2bb2f9..2bb0438c 100644 --- a/tests/test_reconnect_on_tariff_change.cpp +++ b/tests/test_reconnect_on_tariff_change.cpp @@ -9,6 +9,7 @@ #include "teststore.h" #include "testauth.h" #include "testusers.h" +#include "testservices.h" class AFTER_CONNECTED_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { @@ -62,7 +63,8 @@ namespace tut TEST_STORE store; TEST_AUTH auth; TEST_USERS users; - USER_IMPL user(&settings, &store, &tariffs, &admin, &users); + TEST_SERVICES services; + USER_IMPL user(&settings, &store, &tariffs, &admin, &users, services); AFTER_CONNECTED_NOTIFIER connectionNotifier; @@ -119,7 +121,8 @@ namespace tut TEST_STORE store; TEST_AUTH auth; TEST_USERS users; - USER_IMPL user(&settings, &store, &tariffs, &admin, &users); + TEST_SERVICES services; + USER_IMPL user(&settings, &store, &tariffs, &admin, &users, services); AFTER_CONNECTED_NOTIFIER connectionNotifier; diff --git a/tests/testservices.h b/tests/testservices.h new file mode 100644 index 00000000..88e21769 --- /dev/null +++ b/tests/testservices.h @@ -0,0 +1,26 @@ +#ifndef __TEST_SERVICES__ +#define __TEST_SERVICES__ + +#include "stg/services.h" + +class TEST_SERVICES : public SERVICES +{ + public: + virtual int Add(const SERVICE_CONF & /*service*/, const ADMIN * /*admin*/) { return 0; } + virtual int Del(const std::string & /*name*/, const ADMIN * /*admin*/) { return 0; } + virtual int Change(const SERVICE_CONF & /*service*/, const ADMIN * /*admin*/) { return 0; } + virtual bool Find(const std::string & name, SERVICE_CONF * service) const { return false; } + virtual bool Find(const std::string & name, SERVICE_CONF_RES * service) const { return false; } + virtual bool Exists(const std::string & name) const { return false; } + virtual const std::string & GetStrError() const { return m_errorStr; } + virtual size_t Count() const { return 0; } + + virtual int OpenSearch() const { return 0; } + virtual int SearchNext(int, SERVICE_CONF * /*service*/) const { return 0; } + virtual int CloseSearch(int) const { return 0; } + + private: + std::string m_errorStr; +}; + +#endif diff --git a/tests/testusers.h b/tests/testusers.h index 3d3b7931..131fb9b6 100644 --- a/tests/testusers.h +++ b/tests/testusers.h @@ -1,6 +1,8 @@ #ifndef __TEST_USERS_H__ #define __TEST_USERS_H__ +#include "stg/users.h" + class TEST_USERS : public USERS { public: TEST_USERS() {}