smsClientServer_test.h
1 #ifdef TESTING
2 
3 #include <gtest/gtest.h>
4 #include <gmock/gmock.h>
5 
6 #include "../../../../LIBRARIES/UTILS/src/dpyError.h"
7 
8 #include "../src/smsServer.h"
9 #include "../../api/src/smsClient.h"
10 
15 class MockSmsServer : public SmsServer {
16 public:
17  MockSmsServer(boost::asio::io_service& io, int rport, int pport): SmsServer(io, rport, pport) {
18  }
19 
20  MOCK_METHOD3(sendSmsSourcesResponse,void(const std::string &, const std::string &, int));
21  MOCK_METHOD3(sendSmsSourceStatusResponse,void(const std::string &, const std::string &, int));
22 
23  MOCK_METHOD3(sendAllSmsResponse,void(const std::string &, const std::string &, int));
24  MOCK_METHOD3(sendSmsInfoResponse,void(const std::string &, const std::string &, int));
25  MOCK_METHOD3(sendSmsDispatchResponse,void(const std::string &, const std::string &, int));
26 
27 //Do not mock start and stop, otherwise we substitute them and callbacks are not registered
28 
29 };
30 
35 class FakeClient: public SmsClient
36 {
37 public:
38  static boost::system::error_code lastErrorCode;
39  static dpySms::SourceStatus smsSourceStatus;
40 
41  FakeClient(std::string& ip, int dport, int sport) :
42  SmsClient(ip, dport, sport)
43  {
44  }
45 
46 };
47 
48 boost::system::error_code FakeClient::lastErrorCode = DPY_NOT_IMPLEMENTED;
49 dpySms::SourceStatus FakeClient::smsSourceStatus = dpySms::SourceStatus::ENABLED;
50 
51 void sms_sources_handler(boost::system::error_code , __attribute__((unused)) std::list<std::string> sources){
52  FakeClient::lastErrorCode = DPY_OK;
53 }
54 
55 void sms_source_event_handler(boost::system::error_code, __attribute__((unused)) std::string smssourceid, dpySms::SourceStatus event){
56  FakeClient::lastErrorCode = DPY_OK;
57  FakeClient::smsSourceStatus = event;
58 }
59 
60 void get_sms_list_handler(boost::system::error_code, __attribute__((unused))std::map<std::string, dpySms::SmsInformation> &smsList)
61 {
62  FakeClient::lastErrorCode = DPY_OK;
63 
64 }
65 
66 void get_sms_info_handler(boost::system::error_code, __attribute__((unused))const std::string& smsid, __attribute__((unused))const dpySms::SmsInformation &sms_info)
67 {
68  FakeClient::lastErrorCode = DPY_OK;
69 }
70 
71 void send_sms_handler(boost::system::error_code, __attribute__((unused))const std::string& smsid){
72 
73  FakeClient::lastErrorCode = DPY_OK;
74 
75 }
76 
77 #endif //TESTING
78 
SourceStatus
Source Status.
Definition: iVoiceCallSource.h:18
Manages router and publisher.
Definition: smsServer.h:18
Allows to interact with the SMS service.
Definition: smsClient.h:13
ENABLED.
Definition: geofencingApi.h:62