1 // xestiacalendar_icaltasksave.h - Xestia Calendar iCalendar Task Component Save Unit Tests
3 // (c) 2016 Xestia Software Development.
5 // This file is part of Xestia Calendar.
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.
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.
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/calendartask/CalendarTask.h"
21 TEST(iCalendarSaveTask, SaveTaskTests){
23 CalendarTaskObject TestTask;
24 CalendarTaskObject TestTask2;
26 // Load the test journal information.
28 ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask.LoadFile("iCalendarTask-Load1.vcf"));
29 ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask.ValidBaseObject());
31 ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, TestTask.SaveFile("/stupidfilelocation/dontsavehere.ics"));
35 std::string SaveDataComparison = "BEGIN:VCALENDAR\n"
37 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
40 "DTSTAMP:20160131T160000Z\n"
46 TestTask.SaveString(&SaveData);
48 ASSERT_EQ(SaveDataComparison, SaveData);
50 ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask2.LoadFile("iCalendarTask-Load2.vcf"));
51 ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask2.ValidBaseObject());
55 SaveDataComparison = "BEGIN:VCALENDAR\n"
57 "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
59 "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306e1\n"
60 "DTSTAMP;OTHER=PARAM:20160131T104500Z\n"
61 "CLASS;CHOCOLATE=NONE:PUBLIC\n"
62 "COMPLETED;LYING=NEVER:20160131T110100Z\n"
63 "CREATED;CARAMEL=PLEASE:20160131T080000Z\n"
64 "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXAMPLE=TOKEN;MOREDATA=YES:This \n"
65 " is a description of the todo.\n"
66 "DTSTART;VALUE=DATE-TIME;TZID=Europe/Truro;PARAMONE=YES;PARAMTWO=NO:20160131T1\n"
68 "GEO;EXAMPLE=MOOP:20.0;20.0\n"
69 "LAST-MODIFIED;FUTURE=EVEN:20160131T114200Z\n"
70 "LOCATION;ALTREP=\"null:nodata\";LANGUAGE=kw;EXACT=YES:The Crystal Ceiling, Trur\n"
72 "ORGANIZER;CN=ExampleOrganiser;DIR=\"null:nodata\";SENT-BY=\"mailto:organiser.nor\n"
73 " eply@example.com\";LANGUAGE=kw;HAPPY=WEEKS:mailto:organiser@example.com\n"
74 "PERCENT-COMPLETE;DEEP=THOUGHT:42\n"
75 "PRIORITY;STATUS=DEFAULT:5\n"
76 "RECURRENCE-ID;TZID=Europe/Truro;RANGE=THISANDFUTURE;VALUE=DATE;EXAMPLE=DATA:2\n"
78 "SEQUENCE;TEST=YAY:3\n"
79 "STATUS;LANGUAGE=kw;FAVOURITE=BEANS;NOTLIKE=UNKNOWN:2.0;Success\n"
80 "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=kw;FAVOURITE=TOFU;NOTLIKE=NONE:A summar\n"
82 "URL;EXTERNAL=YES:http://www.example.com/\n"
83 "RRULE;TEST=DATA:FREQ=DAILY;COUNT=10\n"
84 "DUE;TZID=Europe/Truro;VALUE=DATE-TIME;TEST=YES:20160131T150000Z\n"
85 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n"
86 "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n"
88 "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n"
89 " pcyBhbiBleGFtcGxlIGZpbGU=\n"
90 "ATTENDEE:Attendee One\n"
91 "ATTENDEE;DELEGATED-FROM=\"mailto:delegated.from@example.com\";DELEGATED-TO=\"mai\n"
92 " lto:delegated.to@example.com\";ROLE=CHAIR;RSVP=TRUE:Attendee Two\n"
93 "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n"
94 " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n"
101 TestTask2.SaveString(&SaveData);
103 ASSERT_EQ(SaveDataComparison, SaveData);