From 1a9e2a6862684d5bbd4a250019e72ec831429fe6 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Fri, 29 Jul 2016 11:10:21 +0100 Subject: [PATCH] Added ConnectionObject interface, FakeConnection object and connection tests --- source/connobject/ConnectionObject.cpp | 35 +++++++++++++ source/connobject/ConnectionObject.h | 45 ++++++++++++++++ source/tests/classes/FakeConnectionObject.cpp | 51 +++++++++++++++++++ source/tests/classes/FakeConnectionObject.h | 44 ++++++++++++++++ ...estiaab_carddav.h => xestiaab_carddav.cpp} | 0 5 files changed, 175 insertions(+) create mode 100644 source/connobject/ConnectionObject.cpp create mode 100644 source/connobject/ConnectionObject.h create mode 100644 source/tests/classes/FakeConnectionObject.cpp create mode 100644 source/tests/classes/FakeConnectionObject.h rename source/tests/{xestiaab_carddav.h => xestiaab_carddav.cpp} (100%) diff --git a/source/connobject/ConnectionObject.cpp b/source/connobject/ConnectionObject.cpp new file mode 100644 index 0000000..9e2e202 --- /dev/null +++ b/source/connobject/ConnectionObject.cpp @@ -0,0 +1,35 @@ +// ConnectionObject.h - ConnectionObject interface +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book 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, version 3 of the license. +// +// Xestia Address Book 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 Xestia Address Book. If not, see + +#include "ConnectionObject.h" + +using namespace std; + +ConnectionObject::ConnectionObject(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL) : + ServerAddress(ServerAddress), ServerPort(ServerPort), ServerUser(ServerUser), ServerPass(ServerPass), ServerSSL(ServerSSL){ + + TestMode = true; + +} + +ConnectionObject::ConnectionObject(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL, string ServerPrefix, string ServerAccount) : + ServerAddress(ServerAddress), ServerPort(ServerPort), ServerUser(ServerUser), ServerPass(ServerPass), ServerSSL(ServerSSL), ServerPrefix(ServerPrefix), ServerAccount(ServerAccount){ + + TestMode = false; + +} diff --git a/source/connobject/ConnectionObject.h b/source/connobject/ConnectionObject.h new file mode 100644 index 0000000..c668814 --- /dev/null +++ b/source/connobject/ConnectionObject.h @@ -0,0 +1,45 @@ +// ConnectionObject.h - ConnectionObject interface header file. +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book 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, version 3 of the license. +// +// Xestia Address Book 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 Xestia Address Book. If not, see + +#include + +class ConnectionObject{ + + public: + ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL); + ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount); + + // Virtual functions to be setup by the inheriting classes. + + virtual void SetupConnectionObject() {}; + virtual ~ConnectionObject() {}; + + protected: + std::string ServerAddress = ""; + unsigned int ServerPort = 8080; + std::string ServerUser = ""; + std::string ServerPass = ""; + std::string ServerPrefix = ""; + std::string ServerAccount = ""; + bool ServerSSL = true; + std::string ErrorMessage = ""; + std::string ErrorBufferMessage = ""; + bool TestMode = false; + private: + +}; \ No newline at end of file diff --git a/source/tests/classes/FakeConnectionObject.cpp b/source/tests/classes/FakeConnectionObject.cpp new file mode 100644 index 0000000..02a20dc --- /dev/null +++ b/source/tests/classes/FakeConnectionObject.cpp @@ -0,0 +1,51 @@ +// FakeConnectionObject.cpp - FakeConnectionObject class +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book 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, version 3 of the license. +// +// Xestia Address Book 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 Xestia Address Book. If not, see + +#include "FakeConnectionObject.h" + +std::string FakeConnectionObject::GetServerAddress(){ + return ServerAddress; +} + +unsigned int FakeConnectionObject::GetServerPort(){ + return ServerPort; +} + +std::string FakeConnectionObject::GetServerUser(){ + return ServerUser; +} + +std::string FakeConnectionObject::GetServerPass(){ + return ServerPass; +} + +std::string FakeConnectionObject::GetServerPrefix(){ + return ServerPrefix; +} + +std::string FakeConnectionObject::GetServerAccount(){ + return ServerAccount; +} + +bool FakeConnectionObject::GetServerSSL(){ + return ServerSSL; +} + +bool FakeConnectionObject::GetTestMode(){ + return TestMode; +} \ No newline at end of file diff --git a/source/tests/classes/FakeConnectionObject.h b/source/tests/classes/FakeConnectionObject.h new file mode 100644 index 0000000..02924f9 --- /dev/null +++ b/source/tests/classes/FakeConnectionObject.h @@ -0,0 +1,44 @@ +// FakeConnectionObject.h - FakeConnectionObject class +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book 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, version 3 of the license. +// +// Xestia Address Book 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 Xestia Address Book. If not, see + +#include "../../connobject/ConnectionObject.h" + +class FakeConnectionObject : public ConnectionObject { + + public: + + // Functions for fake connection object. + + using ConnectionObject::ConnectionObject; + std::string GetServerAddress(); + unsigned int GetServerPort(); + std::string GetServerUser(); + std::string GetServerPass(); + std::string GetServerPrefix(); + std::string GetServerAccount(); + bool GetServerSSL(); + bool GetTestMode(); + + // Variables to set for fake connection object. + + std::string ServerPrefixInput = ""; + + protected: + private: + +}; \ No newline at end of file diff --git a/source/tests/xestiaab_carddav.h b/source/tests/xestiaab_carddav.cpp similarity index 100% rename from source/tests/xestiaab_carddav.h rename to source/tests/xestiaab_carddav.cpp -- 2.39.5