ical.net icon indicating copy to clipboard operation
ical.net copied to clipboard

FreeBusy status not working as expected

Open slovely opened this issue 4 years ago • 0 comments

Hello, apologies, I know this library isn't really maintained any more, but I've found something and it seems like a bug but I am wondering if I am just using it wrong.

Given a calendar event that begins at 9.30am and ends at 10.00am, I have written some code to get the free/busy status for an event that runs from 9.00am -> 10am. It returns 'Free' for the start (9am) as expected but when I pass in a Period it also returns free which doesn't seem to make sense to me, as half that period is busy.

Failing unit test:

        public void GetFreeBusyStatus2()
        {
            Calendar cal = new Calendar();

            CalendarEvent evt = cal.Create<CalendarEvent>();
            evt.Summary = "Test event";
            evt.Start = new CalDateTime(2021, 09, 18, 9, 30, 0);
            evt.End = new CalDateTime(2021, 09, 18, 10, 0, 0);

            var newEventStart = new CalDateTime(2021, 09, 18, 9, 0, 0);
            var newEventEnd = new CalDateTime(2021, 09, 18, 10, 0, 00);
            var freeBusy = cal.GetFreeBusy(new CalDateTime(newEventStart.Date), new CalDateTime(newEventEnd.AddDays(1)));
            
            Assert.AreEqual(FreeBusyStatus.Free, freeBusy.GetFreeBusyStatus(newEventStart), "START");
            Assert.AreEqual(FreeBusyStatus.Busy, freeBusy.GetFreeBusyStatus(new Period(newEventStart, newEventEnd)), "PERIOD");
        }

The final Assert fails. Feel like I may be missing something though, so before I start looking at fixing it, does anyone know if this behaviour is expected?

Many thanks.

slovely avatar Sep 18 '21 15:09 slovely