X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=inline;f=source%2Ftests%2Fxestiacalendar_icaleventload.h;h=865d16aa74a66ba3c4359ca8c6c3762897706140;hb=458747634dbe2c1b972536f9bfb2c1c77f351218;hp=2854ec3d607f9ce0623ae653954c42efcd63e1d7;hpb=98d21dfd279a38c83dcbdd99da8024ffea00d9de;p=xestiacalendar%2F.git
diff --git a/source/tests/xestiacalendar_icaleventload.h b/source/tests/xestiacalendar_icaleventload.h
index 2854ec3..865d16a 100644
--- a/source/tests/xestiacalendar_icaleventload.h
+++ b/source/tests/xestiacalendar_icaleventload.h
@@ -2,7 +2,7 @@
//
// (c) 2016 Xestia Software Development.
//
-// This file is part of Xestia Address Book.
+// This file is part of Xestia Calendar.
//
// Xestia Address Book is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
@@ -14,8 +14,275 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
-// with Xestia Address Book. If not, see
+// with Xestia Calendar. If not, see
-TEST(iCalendarEvent, BasicTest){
+#include "../objects/calendarevent/CalendarEvent.h"
+
+TEST(iCalendarEvent, BasicTests){
+
+ CalendarEventObject TestEvent;
+
+ ASSERT_EQ(CALENDAROBJECTLOAD_MISSING, TestEvent.LoadFile("iCalendarEvent-Missing.vcf"));
+ ASSERT_EQ(CALENDAROBJECTLOAD_CANNOTOPEN, TestEvent.LoadFile("iCalendarEvent-InvalidPermissions.vcf"));
+ ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestEvent.LoadFile("iCalendarEvent-Load1.vcf"));
+
+}
+
+TEST(iCalendarEvent, BaseObjectVerifyTests){
+
+ CalendarEventObject TestEvent;
+ TestEvent.LoadFile("iCalendarEvent-Load1.vcf");
+ ASSERT_EQ(CALENDAROBJECTVALID_OK, TestEvent.ValidBaseObject());
+
+ // Tests for METHOD.
+
+ ASSERT_EQ("REQUEST", TestEvent.MethodData);
+ ASSERT_EQ("EXAMPLE=DATA", TestEvent.MethodTokens);
+
+ // Tests for CALSCALE.
+
+ ASSERT_EQ("GREGORIAN", TestEvent.CalendarScaleData);
+ ASSERT_EQ("MORE=YES", TestEvent.CalendarScaleTokens);
+
+}
+
+TEST(iCalendarEvent, ObjectDataTests){
+
+ CalendarEventObject TestEvent;
+ ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestEvent.LoadFile("iCalendarEvent-Load2.vcf"));
+ ASSERT_EQ(CALENDAROBJECTVALID_OK, TestEvent.ValidBaseObject());
+
+ // Tests for DTSTAMP.
+
+ ASSERT_EQ("20160122T124100Z", TestEvent.DateTimeStampData);
+ ASSERT_EQ("OTHER=PARAM", TestEvent.DateTimeStampTokens);
+
+ // Tests for UID.
+
+ ASSERT_EQ("b3a16392-ad86-4061-be53-c215af2306e0", TestEvent.UniqueID);
+ ASSERT_EQ("UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT", TestEvent.UniqueIDTokens);
+
+ // Tests for DTSTART.
+
+ ASSERT_EQ("20160122T183000Z", TestEvent.DateTimeStartData);
+ ASSERT_EQ("DATE-TIME", TestEvent.DateTimeStartDataValue);
+ ASSERT_EQ("Europe/Truro", TestEvent.DateTimeStartDataTimeZoneID);
+ ASSERT_EQ("PARAMONE=YES;PARAMTWO=NO", TestEvent.DateTimeStartDataTokens);
+
+ // Tests for CLASS.
+
+ ASSERT_EQ("PUBLIC", TestEvent.ClassData);
+ ASSERT_EQ("CHOCOLATE=BAR", TestEvent.ClassDataTokens);
+
+ // Tests for CREATED.
+
+ ASSERT_EQ("20160123T081100Z", TestEvent.DateTimeCreatedData);
+ ASSERT_EQ("CARAMEL=PLEASE", TestEvent.DateTimeCreatedTokens);
+
+ // Tests for DESCRIPTION.
+
+ std::string DescriptionData;
+ std::string DescriptionAltRep;
+ std::string DescriptionLanguage;
+ std::string DescriptionTokens;
+
+ if (TestEvent.DescriptionList.begin() != TestEvent.DescriptionList.end()){
+ DescriptionData = TestEvent.DescriptionList[0];
+ }
+
+ if (TestEvent.DescriptionListAltRep.begin() != TestEvent.DescriptionListAltRep.end()){
+ DescriptionAltRep = TestEvent.DescriptionListAltRep[0];
+ }
+
+ if (TestEvent.DescriptionListAltRep.begin() != TestEvent.DescriptionListAltRep.end()){
+ DescriptionLanguage = TestEvent.DescriptionListLanguage[0];
+ }
+
+ if (TestEvent.DescriptionListTokens.begin() != TestEvent.DescriptionListTokens.end()){
+ DescriptionTokens = TestEvent.DescriptionListTokens[0];
+ }
+
+ ASSERT_EQ("This is a description of the event.", DescriptionData);
+ ASSERT_EQ("null:nodata", DescriptionAltRep);
+ ASSERT_EQ("kw", DescriptionLanguage);
+ ASSERT_EQ("EXAMPLE=TOKEN;MOREDATA=YES", DescriptionTokens);
+
+ // Tests for GEO.
+
+ ASSERT_EQ("5.0;5.0", TestEvent.GeographicData);
+ ASSERT_EQ("EXAMPLE=MEEP", TestEvent.GeographicTokens);
+
+ // Tests for LAST-MODIFIED.
+
+ ASSERT_EQ("20160124T093000Z", TestEvent.LastModifiedData);
+ ASSERT_EQ("FUTURE=ODD", TestEvent.LastModifiedTokens);
+
+ // Tests for LOCATION.
+
+ ASSERT_EQ("The Basement, Truro", TestEvent.LocationData);
+ ASSERT_EQ("null:nodata", TestEvent.LocationDataAltRep);
+ ASSERT_EQ("kw", TestEvent.LocationDataLanguage);
+ ASSERT_EQ("EXACT=NO", TestEvent.LocationDataTokens);
+
+ // Tests for ORGANIZER.
+
+ ASSERT_EQ("mailto:organiser@example.com", TestEvent.OrganiserData);
+ ASSERT_EQ("ExampleOrganiser", TestEvent.OrganiserDataCommonName);
+ ASSERT_EQ("null:nodata", TestEvent.OrganiserDataDirectoryEntry);
+ ASSERT_EQ("mailto:organiser.noreply@example.com", TestEvent.OrganiserDataSentByParam);
+ ASSERT_EQ("kw", TestEvent.OrganiserDataLanguage);
+ ASSERT_EQ("HAPPY=DAYS", TestEvent.OrganiserDataTokens);
+
+ // Tests for PRIORITY.
+
+ ASSERT_EQ(5, TestEvent.PriorityData);
+ ASSERT_EQ("STATUS=DEFAULT", TestEvent.PriorityTokens);
+
+ // Tests for SEQUENCE.
+
+ ASSERT_EQ(3, TestEvent.SequenceData);
+ ASSERT_EQ("TEST=YAY", TestEvent.SequenceTokens);
+
+ // Tests for STATUS.
+
+ ASSERT_EQ("2.0;Success", TestEvent.RequestStatusData);
+ ASSERT_EQ("kw", TestEvent.RequestStatusLanguage);
+ ASSERT_EQ("FAVOURITE=RICHTEA;NOTLIKE=UNKNOWN", TestEvent.RequestStatusTokens);
+
+ // Tests for SUMMARY.
+
+ ASSERT_EQ("A summary of the event.", TestEvent.SummaryData);
+ ASSERT_EQ("null:nodata", TestEvent.SummaryDataAltRep);
+ ASSERT_EQ("kw", TestEvent.SummaryDataLanguage);
+ ASSERT_EQ("FAVOURITE=TOFU;NOTLIKE=NONE", TestEvent.SummaryDataTokens);
+
+ // Tests for TRANSP.
+
+ ASSERT_EQ("TRANSPARENT", TestEvent.TimeTransparencyData);
+ ASSERT_EQ("OPAQUE=NOTYET", TestEvent.TimeTransparencyDataTokens);
+
+ // Tests for URL.
+
+ ASSERT_EQ("http://www.example.com/", TestEvent.URLData);
+ ASSERT_EQ("EXTERNAL=YES", TestEvent.URLDataTokens);
+
+ // Tests for RECURRENCE-ID.
+
+ ASSERT_EQ("20160124", TestEvent.RecurranceIDData);
+ ASSERT_EQ("Europe/Truro", TestEvent.RecurranceIDDataTimeZoneParam);
+ ASSERT_EQ("THISANDFUTURE", TestEvent.RecurranceIDDataRangeParam);
+ ASSERT_EQ("DATE", TestEvent.RecurranceIDDataValue);
+ ASSERT_EQ("EXAMPLE=DATA", TestEvent.RecurranceIDDataTokens);
+
+ // Tests for RRULE.
+
+ ASSERT_EQ("FREQ=DAILY;COUNT=10", TestEvent.RecurranceRuleData);
+ ASSERT_EQ("TEST=DATA", TestEvent.RecurranceRuleDataTokens);
+
+ // Tests for DTEND.
+
+ ASSERT_EQ("20160124T183000Z", TestEvent.DateTimeEndData);
+ ASSERT_EQ("DATE-TIME", TestEvent.DateTimeEndDataValue);
+ ASSERT_EQ("Europe/Truro", TestEvent.DateTimeEndDataTimeZoneID);
+ ASSERT_EQ("PARAMFOUR=YES;PARAMTHREE=NO", TestEvent.DateTimeEndDataTokens);
+
+ // Tests for DURATION. (Done in another file called
+ // iCalendarEvent-Load3.vcf).
+
+ CalendarEventObject TestEvent2;
+ ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestEvent2.LoadFile("iCalendarEvent-Load3.vcf"));
+ ASSERT_EQ(CALENDAROBJECTVALID_OK, TestEvent2.ValidBaseObject());
+
+ ASSERT_EQ("PT1H", TestEvent2.DurationData);
+ ASSERT_EQ("TEST=EXAMPLE", TestEvent2.DurationDataTokens);
+
+ // Tests for ATTACH. First ATTACH property.
+
+ std::string AttachData;
+ std::string AttachDataFormatType;
+ std::string AttachDataValue;
+ std::string AttachDataEncoding;
+ std::string AttachDataTokens;
+
+ if (TestEvent.AttachList.begin() != TestEvent.AttachList.end()){
+
+ AttachData = TestEvent.AttachList[0];
+
+ }
+
+ if (TestEvent.AttachListFormatType.begin() != TestEvent.AttachListFormatType.end()){
+
+ AttachDataFormatType = TestEvent.AttachListFormatType[0];
+
+ }
+
+ ASSERT_EQ("http://www.example.com/", AttachData);
+ ASSERT_EQ("application/internet-shortcut", AttachDataFormatType);
+
+ // Second ATTACH property.
+
+ AttachData.clear();
+ AttachDataFormatType.clear();
+ AttachDataValue.clear();
+ AttachDataEncoding.clear();
+
+ if (TestEvent.AttachList.size() > 1){
+
+ AttachData = TestEvent.AttachList[1];
+
+ }
+
+ if (TestEvent.AttachListFormatType.size() > 1){
+
+ AttachDataFormatType = TestEvent.AttachListFormatType[1];
+
+ }
+
+ ASSERT_EQ("http://www.example.com/page2.html", AttachData);
+ ASSERT_EQ("application/internet-shortcut", AttachDataFormatType);
+
+ // Third ATTACH property.
+
+ AttachData.clear();
+ AttachDataFormatType.clear();
+ AttachDataValue.clear();
+ AttachDataEncoding.clear();
+ AttachDataTokens.clear();
+
+ if (TestEvent.AttachList.size() > 2){
+
+ AttachData = TestEvent.AttachList[2];
+
+ }
+
+ if (TestEvent.AttachListFormatType.size() > 2){
+
+ AttachDataFormatType = TestEvent.AttachListFormatType[2];
+
+ }
+
+ if (TestEvent.AttachListValue.size() > 2){
+
+ AttachDataValue = TestEvent.AttachListValue[2];
+
+ }
+
+ if (TestEvent.AttachListFormatType.size() > 2){
+
+ AttachDataEncoding = TestEvent.AttachListEncoding[2];
+
+ }
+
+ if (TestEvent.AttachListTokens.size() > 2){
+
+ AttachDataTokens = TestEvent.AttachListTokens[2];
+
+ }
+
+ ASSERT_EQ("VGhpcyBpcyBhbiBleGFtcGxlIGZpbGU=", AttachData);
+ ASSERT_EQ("text/plain", AttachDataFormatType);
+ ASSERT_EQ("BASE64", AttachDataEncoding);
+ ASSERT_EQ("BINARY", AttachDataValue);
+ ASSERT_EQ("STUPID=EXAMPLE", AttachDataTokens);
}
\ No newline at end of file