Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
random: Implemented Win32 version
[xestiacalendar/.git] / source / tests / xestiacalendar_icalfreebusyload.h
1 // xestiacalendar_icalfreebusyload.h - Xestia Calendar iCalendar FreeBusy Component Unit Tests
2 //
3 // (c) 2016-2017 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
7 // Xestia Calendar 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 Calendar 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