Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added ATTACH property for saving data from a CalendarEventObject.
[xestiacalendar/.git] / source / tests / xestiacalendar_icalfreebusyload.h
1 // xestiacalendar_icalfreebusyload.h - Xestia Calendar iCalendar FreeBusy Component Unit Tests
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "../objects/calendarfreebusy/CalendarFreeBusy.h"
21 TEST(iCalendarFreeBusy, BasicTests){
23         CalendarFreeBusyObject TestFreeBusy;
24         
25         ASSERT_EQ(CALENDAROBJECTLOAD_MISSING, TestFreeBusy.LoadFile("iCalendarFreeBusy-Missing.vcf"));
26         ASSERT_EQ(CALENDAROBJECTLOAD_CANNOTOPEN, TestFreeBusy.LoadFile("iCalendarFreeBusy-InvalidPermissions.vcf"));
27         ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestFreeBusy.LoadFile("iCalendarFreeBusy-Load1.vcf"));
28         
29 }
31 TEST(iCalendarFreeBusy, ObjectDataTests){
32         
33         CalendarFreeBusyObject TestFreeBusy;
34         ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestFreeBusy.LoadFile("iCalendarFreeBusy-Load2.vcf"));
35         ASSERT_EQ(CALENDAROBJECTVALID_OK, TestFreeBusy.ValidBaseObject());
36         
37         // Tests for DTSTAMP.
38         
39         ASSERT_EQ("20160131T173000Z", TestFreeBusy.DateTimeStampData);
40         ASSERT_EQ("OTHER=PARAM", TestFreeBusy.DateTimeStampTokens);
41         
42         // Tests for UID.
43         
44         ASSERT_EQ("b3a16392-ad86-4061-be53-c215af2306ff", TestFreeBusy.UniqueID);
45         ASSERT_EQ("UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT", TestFreeBusy.UniqueIDTokens);
46         
47         // Tests for CONTACT.
48         
49         std::string ContactData;
50         std::string ContactDataAltRep;
51         std::string ContactDataLanguage;
52         std::string ContactDataTokens;
53         
54         if (TestFreeBusy.ContactList.size() > 0){
55                 
56                 ContactData = TestFreeBusy.ContactList[0];
57                 
58         }
59         
60         if (TestFreeBusy.ContactList.size() > 0){
61                 
62                 ContactDataAltRep = TestFreeBusy.ContactListAltRep[0];
63                 
64         }
65         
66         if (TestFreeBusy.ContactList.size() > 0){
67                 
68                 ContactDataLanguage = TestFreeBusy.ContactListLanguage[0];
69                 
70         }
71         
72         if (TestFreeBusy.ContactList.size() > 0){
73                 
74                 ContactDataTokens = TestFreeBusy.ContactListTokens[0];
75                 
76         }
77         
78         ASSERT_EQ("Contact Person", ContactData);
79         ASSERT_EQ("null:nodata", ContactDataAltRep);
80         ASSERT_EQ("en-GB", ContactDataLanguage);
81         ASSERT_EQ("EXAMPLE=TOKEN", ContactDataTokens);
82         
83         // Tests for DTSTART.
84         
85         ASSERT_EQ("20160131T103000Z", TestFreeBusy.DateTimeStartData);
86         ASSERT_EQ("DATE-TIME", TestFreeBusy.DateTimeStartDataValue);
87         ASSERT_EQ("Europe/Truro", TestFreeBusy.DateTimeStartDataTimeZoneID);
88         ASSERT_EQ("PARAMONE=YES;PARAMTWO=NO", TestFreeBusy.DateTimeStartDataTokens);
90         // Tests for DTEND.
91         
92         ASSERT_EQ("20160131T183000Z", TestFreeBusy.DateTimeEndData);
93         ASSERT_EQ("DATE-TIME", TestFreeBusy.DateTimeEndDataValue);
94         ASSERT_EQ("Europe/Truro", TestFreeBusy.DateTimeEndDataTimeZoneID);
95         ASSERT_EQ("PARAMFOUR=YES;PARAMTHREE=NO", TestFreeBusy.DateTimeEndDataTokens);
96         
97         // Tests for ORGANIZER.
98         
99         ASSERT_EQ("mailto:organiser@example.com", TestFreeBusy.OrganiserData);
100         ASSERT_EQ("ExampleOrganiser", TestFreeBusy.OrganiserDataCommonName);
101         ASSERT_EQ("null:nodata", TestFreeBusy.OrganiserDataDirectoryEntry);
102         ASSERT_EQ("mailto:organiser.noreply@example.com", TestFreeBusy.OrganiserDataSentByParam);
103         ASSERT_EQ("kw", TestFreeBusy.OrganiserDataLanguage);
104         ASSERT_EQ("HAPPY=DAYS", TestFreeBusy.OrganiserDataTokens);
105         
106         // Tests for URL.
108         ASSERT_EQ("http://www.example.com/", TestFreeBusy.URLData);
109         ASSERT_EQ("EXTERNAL=YES", TestFreeBusy.URLDataTokens);
110         
111         // Tests for ATTENDEE. First ATTENDEE property.
113         std::string AttendeeDataMember;
114         std::string AttendeeDataDelegatedFrom;
115         std::string AttendeeDataDelegatedTo;
116         std::string AttendeeDataRole;
117         std::string AttendeeDataRSVP;
118         std::string AttendeeDataDirectoryEntry;
119         std::string AttendeeDataSentBy;
120         std::string AttendeeDataCommonName;
121         std::string AttendeeDataCalendarUserType;
122         std::string AttendeeDataParticipationStatus;
123         std::string AttendeeDataLanguage;
124         std::string AttendeeDataTokens;
125         std::string AttendeeData;
127         if (TestFreeBusy.AttendeeList.begin() != TestFreeBusy.AttendeeList.end()){
128                 
129                 AttendeeData = TestFreeBusy.AttendeeList[0];
130                 
131         }
132         
133         ASSERT_EQ("Attendee One", AttendeeData);
134         
135         // Second ATTENDEE property.
136         
137         AttendeeData.clear();
138         
139         if (TestFreeBusy.AttendeeList.size() > 1){
140                 
141                 AttendeeData = TestFreeBusy.AttendeeList[1];
142                 
143         }
145         if (TestFreeBusy.AttendeeList.size() > 1){
146                 
147                 AttendeeDataDelegatedFrom = TestFreeBusy.AttendeeListDelegatedFrom[1];
148                 
149         }
150         
151         if (TestFreeBusy.AttendeeList.size() > 1){
152                 
153                 AttendeeDataDelegatedTo = TestFreeBusy.AttendeeListDelegatedTo[1];
154                 
155         }
157         if (TestFreeBusy.AttendeeList.size() > 1){
158                 
159                 AttendeeDataRole = TestFreeBusy.AttendeeListRole[1];
160                 
161         }
162         
163         if (TestFreeBusy.AttendeeList.size() > 1){
164                 
165                 AttendeeDataRSVP = TestFreeBusy.AttendeeListRSVP[1];
166                 
167         }
168         
169         ASSERT_EQ("Attendee Two", AttendeeData);
170         ASSERT_EQ("mailto:delegated.from@example.com", AttendeeDataDelegatedFrom);
171         ASSERT_EQ("mailto:delegated.to@example.com", AttendeeDataDelegatedTo);
172         ASSERT_EQ("CHAIR", AttendeeDataRole);
173         ASSERT_EQ("TRUE", AttendeeDataRSVP);
175         // Third ATTENDEE property.
176         
177         AttendeeData.clear();
178         
179         if (TestFreeBusy.AttendeeList.size() > 2){
180                 
181                 AttendeeData = TestFreeBusy.AttendeeList[2];
182                 
183         }
185         if (TestFreeBusy.AttendeeList.size() > 2){
186                 
187                 AttendeeDataDirectoryEntry = TestFreeBusy.AttendeeListDirectoryEntry[2];
188                 
189         }
190         
191         if (TestFreeBusy.AttendeeList.size() > 2){
192                 
193                 AttendeeDataSentBy = TestFreeBusy.AttendeeListSentBy[2];
194                 
195         }
197         if (TestFreeBusy.AttendeeList.size() > 2){
198                 
199                 AttendeeDataCommonName = TestFreeBusy.AttendeeListCommonName[2];
200                 
201         }
202         
203         if (TestFreeBusy.AttendeeList.size() > 2){
204                 
205                 AttendeeDataCalendarUserType = TestFreeBusy.AttendeeListCalendarUserType[2];
206                 
207         }
209         if (TestFreeBusy.AttendeeList.size() > 2){
210                 
211                 AttendeeDataParticipationStatus = TestFreeBusy.AttendeeListParticipationStatus[2];
212                 
213         }
215         if (TestFreeBusy.AttendeeList.size() > 2){
216                 
217                 AttendeeDataLanguage = TestFreeBusy.AttendeeListLanguage[2];
218                 
219         }
220         
221         if (TestFreeBusy.AttendeeList.size() > 2){
222                 
223                 AttendeeDataTokens = TestFreeBusy.AttendeeListTokens[2];
224                 
225         }
226         
227         ASSERT_EQ("Attendee Three", AttendeeData);
228         ASSERT_EQ("null:nodata", AttendeeDataDirectoryEntry);
229         ASSERT_EQ("mailto:sent.by@example.com", AttendeeDataSentBy);
230         ASSERT_EQ("Attendee The Third", AttendeeDataCommonName);
231         ASSERT_EQ("INDIVIDUAL", AttendeeDataCalendarUserType);
232         ASSERT_EQ("ACCEPTED", AttendeeDataParticipationStatus);
233         ASSERT_EQ("kw", AttendeeDataLanguage);
234         ASSERT_EQ("EXAMPLE=DATA", AttendeeDataTokens);
235         
236         // Get the first COMMENT.
237         
238         std::string CommentData;
239         
240         if (TestFreeBusy.CommentList.begin() != TestFreeBusy.CommentList.end()){
241                 
242                 CommentData = TestFreeBusy.CommentList[0];
243                 
244         }
245         
246         ASSERT_EQ("This is the first comment.", CommentData);
247         
248         // Get the second COMMENT.
249         
250         CommentData.clear();
251         
252         std::string CommentDataAltRep;
253         std::string CommentDataLanguage;
254         
255         if (TestFreeBusy.CommentList.size() > 1){
256                 
257                 CommentData = TestFreeBusy.CommentList[1];
258                 
259         }
260         
261         if (TestFreeBusy.CommentList.size() > 1){
262                 
263                 CommentDataAltRep = TestFreeBusy.CommentListAltRep[1];
264                 
265         }
266         
267         if (TestFreeBusy.CommentList.size() > 1){
268                 
269                 CommentDataLanguage = TestFreeBusy.CommentListLanguage[1];
270                 
271         }
272         
273         ASSERT_EQ("This is the second comment.", CommentData);
274         ASSERT_EQ("null:nodata", CommentDataAltRep);
275         ASSERT_EQ("en", CommentDataLanguage);
276         
277         // Get the third COMMENT.
278         
279         CommentData.clear();
280         
281         std::string CommentDataTokens;
282         
283         if (TestFreeBusy.CommentList.size() > 2){
284                 
285                 CommentData = TestFreeBusy.CommentList[2];
286                 
287         }
288         
289         if (TestFreeBusy.CommentList.size() > 2){
290                 
291                 CommentDataTokens = TestFreeBusy.CommentListTokens[2];
292                 
293         }
294         
295         ASSERT_EQ("This is the third comment.", CommentData);
296         ASSERT_EQ("ZEBRAS=YES", CommentDataTokens);
297         
298         // Get the first FREEBUSY.
299         
300         std::string FreeBusyData;
301         
302         if (TestFreeBusy.FreeBusyList.begin() != TestFreeBusy.FreeBusyList.end()){
303                 
304                 FreeBusyData = TestFreeBusy.FreeBusyList[0];
305                 
306         }
307         
308         ASSERT_EQ("20160202T210000Z/PT1H", FreeBusyData);
309         
310         // Get the second FREEBUSY.
311         
312         FreeBusyData.clear();
313         
314         std::string FreeBusyType;
315         
316         if (TestFreeBusy.FreeBusyList.size() > 1){
317                 
318                 FreeBusyData = TestFreeBusy.FreeBusyList[1];
319                 
320         }
321         
322         if (TestFreeBusy.FreeBusyListType.size() > 1){
323                 
324                 FreeBusyType = TestFreeBusy.FreeBusyListType[1];
325                 
326         }
328         ASSERT_EQ("FREE", FreeBusyType);        
329         ASSERT_EQ("20160202T220000Z/PT1H", FreeBusyData);       
330         
331         // Get the third FREEBUSY.
332         
333         FreeBusyData.clear();
334         FreeBusyType.clear();
335         
336         std::string FreeBusyTokens;
337         
338         if (TestFreeBusy.FreeBusyList.size() > 2){
339                 
340                 FreeBusyData = TestFreeBusy.FreeBusyList[2];
341                 
342         }
343         
344         if (TestFreeBusy.FreeBusyListType.size() > 2){
345                 
346                 FreeBusyType = TestFreeBusy.FreeBusyListType[2];
347                 
348         }
349         
350         if (TestFreeBusy.FreeBusyListTokens.size() > 2){
351                 
352                 FreeBusyTokens = TestFreeBusy.FreeBusyListTokens[2];
353                 
354         }
356         ASSERT_EQ("BUSY-UNAVAILABLE", FreeBusyType);    
357         ASSERT_EQ("20160202T230000Z/PT9H", FreeBusyData);
358         ASSERT_EQ("RESULT=ARGH;TEST=YES", FreeBusyTokens);
359         
360         // Get the first REQUEST-STATUS.
362         std::string RequestStatus;
363         
364         if (TestFreeBusy.RequestStatusData.begin() != TestFreeBusy.RequestStatusData.end()){
365                 
366                 RequestStatus = TestFreeBusy.RequestStatusData[0];
367                 
368         }
369         
370         ASSERT_EQ("2.0;Success", RequestStatus);
371         
372         // Get the second REQUEST-STATUS.
373         
374         RequestStatus.clear();
375         
376         std::string RequestLanguage;
377         
378         if (TestFreeBusy.RequestStatusData.size() > 1){
379                 
380                 RequestStatus = TestFreeBusy.RequestStatusData[1];
381                 
382         }
383         
384         if (TestFreeBusy.RequestStatusData.size() > 1){
385                 
386                 RequestLanguage = TestFreeBusy.RequestStatusLanguage[1];
387                 
388         }
389         
390         ASSERT_EQ("3.42;Really big irrecoverable error caused by the user", RequestStatus);
391         ASSERT_EQ("en", RequestLanguage);
392         
393         // Get the third REQUEST-STATUS.
394         
395         RequestStatus.clear();
396         
397         std::string RequestTokens;
398         
399         if (TestFreeBusy.RequestStatusData.size() > 2){
400                 
401                 RequestStatus = TestFreeBusy.RequestStatusData[2];
402                 
403         }
404         
405         if (TestFreeBusy.RequestStatusData.size() > 2){
406                 
407                 RequestTokens = TestFreeBusy.RequestStatusTokens[2];
408                 
409         }
410         
411         ASSERT_EQ("3.7;Invalid calendar user", RequestStatus);
412         ASSERT_EQ("USER=MISSING", RequestTokens);
413         
414         // Get the first X-EXAMPLE1 token.
415         
416         std::string XTokenName;
417         std::string XTokenData;
418         
419         if (TestFreeBusy.XTokensData.size() != 0 ){
420         
421                 XTokenData = TestFreeBusy.XTokensData[0];
422                 
423         }
425         if (TestFreeBusy.XTokensData.size() != 0){
426         
427                 XTokenName = TestFreeBusy.XTokensDataTokens[0];
428                 
429         }
430         
431         ASSERT_EQ("Moo", XTokenData);
432         ASSERT_EQ("X-EXAMPLE1", XTokenName);
433         
434         // Get the second X-EXAMPLE1 token.
436         XTokenName.clear();
437         XTokenData.clear();
438         
439         if (TestFreeBusy.XTokensData.size() > 1){
440         
441                 XTokenData = TestFreeBusy.XTokensData[1];
442                 
443         }
445         if (TestFreeBusy.XTokensData.size() > 1){
446         
447                 XTokenName = TestFreeBusy.XTokensDataTokens[1];
448                 
449         }
450         
451         ASSERT_EQ("Meep", XTokenData);
452         ASSERT_EQ("X-EXAMPLE1;ANIMAL=NOPE", XTokenName);
453         
454         // Get the third X-EXAMPLE1 token.
456         XTokenName.clear();
457         XTokenData.clear();
458         
459         if (TestFreeBusy.XTokensData.size() > 2){
460         
461                 XTokenData = TestFreeBusy.XTokensData[2];
462                 
463         }
465         if (TestFreeBusy.XTokensData.size() > 2){
466         
467                 XTokenName = TestFreeBusy.XTokensDataTokens[2];
468                 
469         }
470         
471         ASSERT_EQ("Meow", XTokenData);
472         ASSERT_EQ("X-EXAMPLE1;ANIMAL=CAT", XTokenName);
473         
474         // Get the first X-EXAMPLE2 token.
475         
476         XTokenName.clear();
477         XTokenData.clear();
478         
479         if (TestFreeBusy.XTokensData.size() > 3){
480         
481                 XTokenData = TestFreeBusy.XTokensData[3];
482                 
483         }
485         if (TestFreeBusy.XTokensData.size() > 3){
486         
487                 XTokenName = TestFreeBusy.XTokensDataTokens[3];
488                 
489         }
490         
491         ASSERT_EQ("Dish", XTokenData);
492         ASSERT_EQ("X-EXAMPLE2", XTokenName);
493         
494         // Get the second X-EXAMPLE2 token.
495         
496         XTokenName.clear();
497         XTokenData.clear();
498         
499         if (TestFreeBusy.XTokensData.size() > 4){
500         
501                 XTokenData = TestFreeBusy.XTokensData[4];
502                 
503         }
505         if (TestFreeBusy.XTokensData.size() > 4){
506         
507                 XTokenName = TestFreeBusy.XTokensDataTokens[4];
508                 
509         }
510         
511         ASSERT_EQ("Fork", XTokenData);
512         ASSERT_EQ("X-EXAMPLE2;OBJECT=KITCHEN", XTokenName);
513         
514         // Get the third X-EXAMPLE2 token.
515         
516         XTokenName.clear();
517         XTokenData.clear();
518         
519         if (TestFreeBusy.XTokensData.size() > 5){
520         
521                 XTokenData = TestFreeBusy.XTokensData[5];
522                 
523         }
525         if (TestFreeBusy.XTokensData.size() > 5){
526         
527                 XTokenName = TestFreeBusy.XTokensDataTokens[5];
528                 
529         }
530         
531         ASSERT_EQ("Table", XTokenData);
532         ASSERT_EQ("X-EXAMPLE2;OBJECT=LIVINGROOM", XTokenName);
533         
534         // Get the X-STATUS token.
535         
536         XTokenName.clear();
537         XTokenData.clear();
538         
539         if (TestFreeBusy.XTokensData.size() > 6){
540         
541                 XTokenData = TestFreeBusy.XTokensData[6];
542                 
543         }
545         if (TestFreeBusy.XTokensData.size() > 6){
546         
547                 XTokenName = TestFreeBusy.XTokensDataTokens[6];
548                 
549         }
550         
551         ASSERT_EQ("Idle", XTokenData);
552         ASSERT_EQ("X-STATUS;HOLIDAY=YES", XTokenName);
553         
554         // Get the X-TRANSPORT token.
555         
556         XTokenName.clear();
557         XTokenData.clear();
558         
559         if (TestFreeBusy.XTokensData.size() > 7){
560         
561                 XTokenData = TestFreeBusy.XTokensData[7];
562                 
563         }
565         if (TestFreeBusy.XTokensData.size() > 7){
566         
567                 XTokenName = TestFreeBusy.XTokensDataTokens[7];
568                 
569         }
570         
571         ASSERT_EQ("Private Hire", XTokenData);
572         ASSERT_EQ("X-TRANSPORT;PUBLIC=NO", XTokenName);
573         
574         // Get the X-PHANTOM-STATUS token.
575         
576         XTokenName.clear();
577         XTokenData.clear();
578         
579         if (TestFreeBusy.XTokensData.size() > 8){
580         
581                 XTokenData = TestFreeBusy.XTokensData[8];
582                 
583         }
585         if (TestFreeBusy.XTokensData.size() > 8){
586         
587                 XTokenName = TestFreeBusy.XTokensDataTokens[8];
588                 
589         }
590         
591         ASSERT_EQ("None", XTokenData);
592         ASSERT_EQ("X-PHANTOM-STATUS;HELP=NONE", XTokenName);
593         
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