From d2f1e7f0975a5dabc007a5633df5f7266bbdfc7c Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 13 Feb 2017 22:06:05 +0000 Subject: [PATCH] CardDAV2: Fixed FakeConnectionObject unit tests --- source/tests/classes/FakeConnectionObject.cpp | 31 ++++++++++++++++++- source/tests/classes/FakeConnectionObject.h | 20 ++++++++---- source/tests/xestiaab_carddav.cpp | 8 +++++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/source/tests/classes/FakeConnectionObject.cpp b/source/tests/classes/FakeConnectionObject.cpp index 348956c..4a348a5 100644 --- a/source/tests/classes/FakeConnectionObject.cpp +++ b/source/tests/classes/FakeConnectionObject.cpp @@ -18,6 +18,35 @@ #include "FakeConnectionObject.h" +FakeConnectionObject::FakeConnectionObject(std::string ServerAddress, int ServerPort, + std::string ServerUser, std::string ServerPass, bool ServerSSL){ + + this->ServerAddress = ServerAddress; + this->ServerPort = ServerPort; + this->ServerUser = ServerUser; + this->ServerPass = ServerPass; + this->ServerSSL = ServerSSL; + +} + +FakeConnectionObject::FakeConnectionObject(std::string ServerAddress, int ServerPort, + std::string ServerUser, std::string ServerPass, bool ServerSSL, + std::string ServerPrefix, std::string ServerAccount){ + + this->ServerAddress = ServerAddress; + this->ServerPort = ServerPort; + this->ServerUser = ServerUser; + this->ServerPass = ServerPass; + this->ServerSSL = ServerSSL; + this->ServerPrefix = ServerPrefix; + this->ServerAccount = ServerAccount; + +} + +FakeConnectionObject::~FakeConnectionObject(){ + +} + COConnectResult FakeConnectionObject::Connect(bool DoAuthentication){ COConnectResult ConnectResult = ResultStatus; @@ -154,7 +183,7 @@ bool FakeConnectionObject::GetServerSSL(){ } bool FakeConnectionObject::GetTestMode(){ - return TestMode; + return ResultTestMode; } bool FakeConnectionObject::CanDoProcessing(){ diff --git a/source/tests/classes/FakeConnectionObject.h b/source/tests/classes/FakeConnectionObject.h index 9a214a7..41f5ce4 100644 --- a/source/tests/classes/FakeConnectionObject.h +++ b/source/tests/classes/FakeConnectionObject.h @@ -25,7 +25,14 @@ class FakeConnectionObject : public ConnectionObject { public: - using ConnectionObject::ConnectionObject; + //using ConnectionObject::ConnectionObject; + + FakeConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL); + FakeConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount); + + // Destructor. + + ~FakeConnectionObject(); // Functions for fake connection object. @@ -72,14 +79,15 @@ class FakeConnectionObject : public ConnectionObject { bool ResultTaskCompleted = false; CORequestResult TestRequestResult; COContactList TestContactList; - std::string TestEntityTag; - int TestSessionCode; - int TestResultCode; - std::string TestResultMessage; + std::string TestEntityTag = ""; + int TestSessionCode = 0; + int TestResultCode = 0; + std::string TestResultMessage = ""; + bool ResultTestMode = false; protected: private: }; -#endif \ No newline at end of file +#endif diff --git a/source/tests/xestiaab_carddav.cpp b/source/tests/xestiaab_carddav.cpp index e205c9b..a4fa5ec 100644 --- a/source/tests/xestiaab_carddav.cpp +++ b/source/tests/xestiaab_carddav.cpp @@ -41,6 +41,10 @@ TEST(CardDAV, Use_Fake_To_Setup_And_Check_Connection_Settings_With_TestMode_True FakeConnectionObject FakeConnection2(ServerAddress2, 8800, ServerUser2, ServerPass2, true); FakeConnectionObject FakeConnection3(ServerAddress3, 8008, ServerUser3, ServerPass3, false); + FakeConnection1.ResultTestMode = true; + FakeConnection2.ResultTestMode = true; + FakeConnection3.ResultTestMode = true; + EXPECT_EQ("gibberish.invalid", FakeConnection1.GetServerAddress()); EXPECT_EQ(8080, FakeConnection1.GetServerPort()); EXPECT_EQ("user", FakeConnection1.GetServerUser()); @@ -88,6 +92,10 @@ TEST(CardDAV, Use_Fake_To_Setup_And_Check_Connection_Settings_With_TestMode_Fals FakeConnectionObject FakeConnection2(ServerAddress2, 8800, ServerUser2, ServerPass2, true, "/prefix2", "Account2"); FakeConnectionObject FakeConnection3(ServerAddress3, 8008, ServerUser3, ServerPass3, false, "/prefix3", "Account3"); + FakeConnection1.ResultTestMode = false; + FakeConnection2.ResultTestMode = false; + FakeConnection3.ResultTestMode = false; + EXPECT_EQ("gibberish.invalid", FakeConnection1.GetServerAddress()); EXPECT_EQ(8080, FakeConnection1.GetServerPort()); EXPECT_EQ("user", FakeConnection1.GetServerUser()); -- 2.39.5