X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiacalendar_caldav.h;h=8ce08ddb2de4484b4116e785cacb0de75ad20d78;hb=e5ba41e02b0bfffed3f8d087f7a49e5fa617005f;hp=f156b2abf744b663cc600124c87b31b44a25e99f;hpb=8916c05c5281bf0c97419df6e7ce6d641c56fb3e;p=xestiacalendar%2F.git diff --git a/source/tests/xestiacalendar_caldav.h b/source/tests/xestiacalendar_caldav.h index f156b2a..8ce08dd 100644 --- a/source/tests/xestiacalendar_caldav.h +++ b/source/tests/xestiacalendar_caldav.h @@ -710,4 +710,98 @@ TEST(CalDAV, EditCalendar){ ASSERT_EQ(CURLE_OK, ConnResult.Code); } + +TEST(CalDAV, DeleteCalendar){ + + 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 list of calendars. + + CalDAVCalendarList CalendarList = ServerConnection.GetCalendars(); + + // Check the response result from the server. + + ConnResult = ServerConnection.GetServerResult(); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(207, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + + // Get the calendar with the matching name. + + int ItemSeek = 0; + bool ItemFound = false; + + for (map::iterator CalendarNameIter = CalendarList.Name.begin(); + CalendarNameIter != CalendarList.Name.end(); CalendarNameIter++){ + + if (CalendarNameIter->second == "Calendar Edited Again"){ + ItemFound = true; + break; + } + + ItemSeek++; + + } + + ASSERT_NE(false, ItemFound); + + // Delete some calendars. + + string CalendarEditHREF = CalendarList.HREF[ItemSeek]; + + cout << CalendarEditHREF << endl; + + ConnResult = ServerConnection.DeleteCalendar(&CalendarEditHREF); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(204, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + } \ No newline at end of file