Skip to content

Commit

Permalink
Merge pull request #516 from rianjs/FixIsActive2
Browse files Browse the repository at this point in the history
Closes #449, fixing an IsActive bug thanks to thoemy
  • Loading branch information
rianjs committed Apr 10, 2021
2 parents a9a2bc7 + 5222b5c commit 9f5a5dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions net-core/Ical.Net.CoreUnitTests/IcsFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ internal static string ReadStream(string manifestResource)
internal static string Event2 => ReadStream("Ical.Net.CoreUnitTests.Calendars.Serialization.Event2.ics");
internal static string Event3 => ReadStream("Ical.Net.CoreUnitTests.Calendars.Serialization.Event3.ics");
internal static string Event4 => ReadStream("Ical.Net.CoreUnitTests.Calendars.Serialization.Event4.ics");
internal static string EventStatus => ReadStream("Ical.Net.CoreUnitTests.Calendars.Serialization.EventStatus.ics");
internal static string GeographicLocation1 => ReadStream("Ical.Net.CoreUnitTests.Calendars.Serialization.GeographicLocation1.ics");
internal static string Google1 => ReadStream("Ical.Net.CoreUnitTests.Calendars.Serialization.Google1.ics");
internal static string Hourly1 => ReadStream("Ical.Net.CoreUnitTests.Calendars.Recurrence.Hourly1.ics");
Expand Down
23 changes: 23 additions & 0 deletions net-core/Ical.Net.CoreUnitTests/SimpleDeserializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,29 @@ public void DateTime1()
Assert.AreEqual(DateTime.MinValue, evt.Created.Value);
}

[Test, Category("Deserialization"), Ignore("Ignore until @thoemy commits the EventStatus.ics file")]
public void EventStatus()
{
var iCal = SimpleDeserializer.Default.Deserialize(new StringReader(IcsFiles.EventStatus)).Cast<Calendar>().Single();
Assert.AreEqual(4, iCal.Events.Count);

Assert.AreEqual("No status", iCal.Events[0].Summary);
Assert.IsNull(iCal.Events[0].Status);
Assert.IsTrue(iCal.Events[0].IsActive);

Assert.AreEqual("Confirmed", iCal.Events[1].Summary);
Assert.AreEqual("CONFIRMED", iCal.Events[1].Status);
Assert.IsTrue(iCal.Events[1].IsActive);

Assert.AreEqual("Cancelled", iCal.Events[2].Summary);
Assert.AreEqual("CANCELLED", iCal.Events[2].Status);
Assert.IsFalse(iCal.Events[2].IsActive);

Assert.AreEqual("Tentative", iCal.Events[3].Summary);
Assert.AreEqual("TENTATIVE", iCal.Events[3].Status);
Assert.IsTrue(iCal.Events[3].IsActive);
}

[Test, Category("Deserialization")]
public void Language4()
{
Expand Down
2 changes: 1 addition & 1 deletion net-core/Ical.Net/CalendarComponents/CalendarEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public virtual bool OccursAt(IDateTime dateTime)
/// as an upcoming or occurred event.
/// </summary>
/// <returns>True if the event has not been cancelled, False otherwise.</returns>
public virtual bool IsActive => string.Equals(Status, EventStatus.Cancelled, EventStatus.Comparison);
public virtual bool IsActive => !string.Equals(Status, EventStatus.Cancelled, EventStatus.Comparison);

protected override bool EvaluationIncludesReferenceDate => true;

Expand Down

0 comments on commit 9f5a5dc

Please sign in to comment.