private CalendarItemType CreateAndGetRecurringCalendarItem(DateTime start, int numberOfOccurrences)
{
#region Step 1: Create a recurring calendar item.
CalendarItemType[] items = new CalendarItemType[] { new CalendarItemType() };
items[0].Subject = Common.GenerateResourceName(
this.Site,
TestSuiteHelper.SubjectForCreateItem);
items[0].Recurrence = new RecurrenceType();
DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
pattern.Interval = 1;
NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
range.NumberOfOccurrences = numberOfOccurrences;
range.StartDate = start;
items[0].Recurrence.Item = pattern;
items[0].Recurrence.Item1 = range;
CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.calendar, items);
// Check the operation response.
Common.CheckOperationSuccess(createItemResponse, 1, this.Site);
ItemIdType[] createdCalendarItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);
// One created calendar item should be returned.
Site.Assert.AreEqual<int>(
1,
createdCalendarItemIds.GetLength(0),
"One created calendar item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
1,
createdCalendarItemIds.GetLength(0));
#endregion
#region Step 2: Get the recurring calendar item by ItemIdType.
// Call the GetItem operation.
GetItemResponseType getItemResponse = this.CallGetItemOperation(createdCalendarItemIds);
// Check the operation response.
Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
CalendarItemType[] getCalendarItems = Common.GetItemsFromInfoResponse<CalendarItemType>(getItemResponse);
// One calendar item should be returned.
Site.Assert.AreEqual<int>(
1,
getCalendarItems.GetLength(0),
"One calendar item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
1,
getCalendarItems.GetLength(0));
Site.Assert.IsNotNull(
getCalendarItems[0].FirstOccurrence,
"FirstOccurrence element in calendar item should not be null!");
return getCalendarItems[0];
#endregion
}
#endregion