Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added unit tests for ConnectionObject interface and FakeConnectionObject class
[xestiaab/.git] / source / tests / xestiaab_carddav.cpp
index eb9acf5..2ef1225 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <gtest/gtest.h>
 #include "classes/FakeConnectionObject.h"
+#include <chrono>
+#include <thread>
 
 // TODO: Add tests for the CardDAV object.
 
@@ -244,10 +246,10 @@ TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_Valid_SSL_Certificate_D
        std::string ServerPass1 = "pass";
        
        FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
-       FakeConnection.ResultSSLVerified = true;
+       FakeConnection.ResultSSLVerified = COSSL_VERIFIED;
        FakeConnection.Connect();
        
-       EXPECT_EQ(true, FakeConnection.SSLVerify());
+       EXPECT_EQ(COSSL_VERIFIED, FakeConnection.SSLVerify());
        
 }
 
@@ -258,10 +260,38 @@ TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_Invalid_SSL_Certificate
        std::string ServerPass1 = "pass";
        
        FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
-       FakeConnection.ResultSSLVerified = false;
+       FakeConnection.ResultSSLVerified = COSSL_UNABLETOVERIFY;
        FakeConnection.Connect();
        
-       EXPECT_EQ(false, FakeConnection.SSLVerify());
+       EXPECT_EQ(COSSL_UNABLETOVERIFY, FakeConnection.SSLVerify());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_User_Verified_SSL_Cerficiate_Data){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultSSLVerified = COSSL_VERIFIED_USER;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(COSSL_VERIFIED_USER, FakeConnection.SSLVerify());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Doesnt_Use_SSL_Return_Not_Applicable_SSL_Result){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, false);
+       FakeConnection.ResultSSLVerified = COSSL_NOTAPPLICABLE;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(COSSL_NOTAPPLICABLE, FakeConnection.SSLVerify());
        
 }
 
@@ -1193,4 +1223,26 @@ TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_A_Contact_List
 
        EXPECT_EQ(0, ServerDataResult.ListData.size());
 
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Wait_For_A_Completed_Task){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+       FakeConnection.ResultServerPrefix = "/prefix/test/b";
+       FakeConnection.Connect();
+       FakeConnection.ResultTaskCompleted = false;
+       
+       while (!FakeConnection.IsTaskCompleted()){
+               
+               std::this_thread::sleep_for(std::chrono::milliseconds(250));
+               FakeConnection.ResultTaskCompleted = true;
+               
+       }
+       
+       EXPECT_TRUE(FakeConnection.ResultTaskCompleted);
+       
 }
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy