Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added unit tests for the GetEntryList functions in the CalDAV object.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 29 May 2016 19:26:59 +0000 (20:26 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 29 May 2016 19:26:59 +0000 (20:26 +0100)
source/tests/xestiacalendar_caldav.h

index 75376da..7b32b1d 100644 (file)
@@ -1163,4 +1163,106 @@ TEST(CalDAV, DeleteEntry){
        ASSERT_EQ(204, ConnResult.HTTPCode);
        ASSERT_EQ(CURLE_OK, ConnResult.Code);
        
+}
+
+TEST(CalDAV, GetEntryList){
+       
+       // Check that EntryCalendarHREFProcessing is not blank. 
+       
+       ASSERT_NE("", EntryCalendarHREFProcessing);
+       
+       CalDAVConnectionData ConnNormal;
+       string CurrentUserPrincipal;
+
+       bool ValidDataNormal = false;
+       
+       // Attempt to read the caldavtest.auth file.
+
+       ProcessConnectionDataFileResult DataFileResult = ProcessConnectionDataFile("caldavtest.auth", &ConnNormal);
+       if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){
+               ValidDataNormal = true;
+       }
+
+       ASSERT_EQ(true, ValidDataNormal);
+       
+       // Setup the connection.
+       
+       CalDAV ServerConnection;
+       
+       ServerConnection.SetupConnectionData(&ConnNormal);
+       
+       // Verify the connection settings.
+       
+       CalDAVStatus CalDAVStatus = ServerConnection.GetConnectionData();
+       
+       ASSERT_EQ(CalDAVStatus.Hostname, ConnNormal.Hostname);
+       ASSERT_EQ(CalDAVStatus.Username, ConnNormal.Username);
+       ASSERT_EQ(CalDAVStatus.Port, ConnNormal.Port);
+       ASSERT_EQ(CalDAVStatus.Prefix, ConnNormal.Prefix);
+       ASSERT_EQ(CalDAVStatus.UseSSL, ConnNormal.UseSSL);
+       
+       // Connect to the server.
+       
+       CalDAVServerResult ConnResult = ServerConnection.Connect();
+       
+       EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
+       ASSERT_EQ(200, ConnResult.HTTPCode);
+       ASSERT_EQ(CURLE_OK, ConnResult.Code);
+       
+       // Check that the server supports CalDAV.
+       
+       CalDAVServerSupport ConnSupport = ServerConnection.GetServerSupport();
+       ConnResult = ServerConnection.GetServerResult();
+       
+       EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
+       ASSERT_EQ(200, ConnResult.HTTPCode);
+       ASSERT_EQ(CURLE_OK, ConnResult.Code);
+       ASSERT_EQ(true, ConnSupport.BasicSupport);
+       
+       // Get the user principal.
+       
+       string UserPrincipalURI = ServerConnection.GetUserPrincipal();
+       
+       // Get the calendar home.
+       
+       string CalendarHomeURL = ServerConnection.GetCalendarHome(UserPrincipalURI);
+
+       string CalendarHREF = CalendarHomeURL;
+       CalendarHREF += "unittestcal/";
+
+       // Get the entry list without a calendar tag set.
+       
+       CalDAVEntryList EntryList = ServerConnection.GetEntryList(&CalendarHREF);
+
+       EXPECT_GE(EntryList.HREF.size(), 1);
+
+       // Get the list of calendars.
+       
+       CalDAVCalendarList CalendarList = ServerConnection.GetCalendars();
+
+       string CalendarTagURL = "";
+
+       for (std::map<int,string>::iterator CalHREFIter = CalendarList.HREF.begin();
+               CalHREFIter != CalendarList.HREF.end(); CalHREFIter++){
+                       
+               if (CalHREFIter->second.substr(CalHREFIter->second.length() - 13) == "/unittestcal/"){
+                       
+                       CalendarTagURL = CalendarList.TagURL.find(CalHREFIter->first)->second;
+                       
+               }
+                       
+       }
+
+       // Get the entry list without a calendar tag set (shouldn't be empty).
+       
+       EntryList = ServerConnection.GetEntryList(&CalendarHREF, nullptr);
+
+       EXPECT_GE(EntryList.HREF.size(), 1);
+       
+       // Get the entry list with a calendar tag set (should be empty).
+       
+       EntryList = ServerConnection.GetEntryList(&CalendarHREF, &CalendarTagURL);
+
+       EXPECT_EQ(EntryList.HREF.size(), 0);
+
 }
\ 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