// xestiacalendar_icaleventload.h - Xestia Calendar iCalendar Event Component Unit Tests // // (c) 2016 Xestia Software Development. // // 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 // Free Software Foundation, version 3 of the license. // // Xestia Address Book is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with Xestia Calendar. If not, see #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); }