示例#1
0
 /// <summary>
 /// Extract the start time of next occurrence for a DailyRecurrencePatternType task item.
 /// </summary>
 /// <param name="taskItem">The task item with daily recurrence pattern.</param>
 /// <returns>The start date time string of next occurrence.</returns>
 private static string ExtractStartTimeOfNextOccurrence(TaskType taskItem)
 {
     if (taskItem != null && taskItem.Recurrence != null && taskItem.Recurrence.Item != null && taskItem.Recurrence.Item1 != null)
     {
         DailyRecurrencePatternType dailyRecurrencePattern = taskItem.Recurrence.Item as DailyRecurrencePatternType;
         return(taskItem.StartDate.AddDays(dailyRecurrencePattern.Interval).ToShortTimeString());
     }
     else
     {
         return(null);
     }
 }
        private RecurrencePattern ConvertRecurrencePattern(RecurrencePatternBaseType pattern)
        {
            DailyRecurrencePatternType dailyRecurrencePatternType = pattern as DailyRecurrencePatternType;

            if (dailyRecurrencePatternType != null)
            {
                return(new DailyRecurrencePattern(dailyRecurrencePatternType.Interval));
            }
            AbsoluteMonthlyRecurrencePatternType absoluteMonthlyRecurrencePatternType = pattern as AbsoluteMonthlyRecurrencePatternType;

            if (absoluteMonthlyRecurrencePatternType != null)
            {
                return(new MonthlyRecurrencePattern(absoluteMonthlyRecurrencePatternType.DayOfMonth, absoluteMonthlyRecurrencePatternType.Interval));
            }
            RelativeMonthlyRecurrencePatternType relativeMonthlyRecurrencePatternType = pattern as RelativeMonthlyRecurrencePatternType;

            if (relativeMonthlyRecurrencePatternType != null)
            {
                return(new MonthlyThRecurrencePattern(this.ConvertDaysOfWeek(relativeMonthlyRecurrencePatternType.DaysOfWeek), this.Convert(relativeMonthlyRecurrencePatternType.DayOfWeekIndex), relativeMonthlyRecurrencePatternType.Interval));
            }
            RelativeYearlyRecurrencePatternType relativeYearlyRecurrencePatternType = pattern as RelativeYearlyRecurrencePatternType;

            if (relativeYearlyRecurrencePatternType != null)
            {
                return(new YearlyThRecurrencePattern(this.ConvertDaysOfWeek(relativeYearlyRecurrencePatternType.DaysOfWeek), this.Convert(relativeYearlyRecurrencePatternType.DayOfWeekIndex), this.ConvertMonth(relativeYearlyRecurrencePatternType.Month)));
            }
            WeeklyRecurrencePatternType weeklyRecurrencePatternType = pattern as WeeklyRecurrencePatternType;

            if (weeklyRecurrencePatternType != null)
            {
                return(new WeeklyRecurrencePattern(this.ConvertDaysOfWeek(weeklyRecurrencePatternType.DaysOfWeek), weeklyRecurrencePatternType.Interval));
            }
            AbsoluteYearlyRecurrencePatternType absoluteYearlyRecurrencePatternType = pattern as AbsoluteYearlyRecurrencePatternType;

            if (absoluteYearlyRecurrencePatternType != null)
            {
                return(new YearlyRecurrencePattern(absoluteYearlyRecurrencePatternType.DayOfMonth, this.ConvertMonth(absoluteYearlyRecurrencePatternType.Month)));
            }
            AppointmentTranslator.Tracer.TraceError <AppointmentTranslator, RecurrencePatternBaseType>((long)this.GetHashCode(), "{0}: Unknown recurrence pattern: {1}", this, pattern);
            throw new InvalidAppointmentException();
        }
示例#3
0
        public void MSOXWSMTGS_S03_TC03_CopyRecurringCalendar()
        {
            #region Define a recurring calendar item
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate           = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID              = Guid.NewGuid().ToString();
            calendarItem.Subject          = this.Subject;
            calendarItem.Start            = startTime;
            calendarItem.StartSpecified   = true;
            calendarItem.End              = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified     = true;
            calendarItem.Recurrence       = new RecurrenceType();
            calendarItem.Recurrence.Item  = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);

            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey         = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex     = this.InstanceIndex;
            #endregion

            #region Get the targeted occurrence item
            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId);
            Site.Assert.IsNotNull(getItem, @"Get the occurrence should be successful.");

            RecurringMasterItemIdType recurringMasterItemId = new RecurringMasterItemIdType();
            recurringMasterItemId.ChangeKey    = getItem.Items.Items[0].ItemId.ChangeKey;
            recurringMasterItemId.OccurrenceId = getItem.Items.Items[0].ItemId.Id;
            #endregion

            #region Copy the recurring calendar item to Drafts folder through Id of recurring master getItem
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.drafts;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            ItemInfoResponseMessageType copiedItem = this.CopySingleCalendarItem(Role.Organizer, recurringMasterItemId, targetFolderId);
            Site.Assert.IsNotNull(copiedItem, @"Copy recurring calendar item through RecurringMasterItemId should be successful.");
            ItemIdType calendarIdByCopied = copiedItem.Items.Items[0].ItemId;
            #endregion

            #region Call GetItem operation to verify whether the recurring calendar item is really copied
            getItem = this.GetSingleCalendarItem(Role.Organizer, calendarIdByCopied);

            if (Common.IsRequirementEnabled(806, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R806");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R806
                this.Site.CaptureRequirementIfIsNotNull(
                    getItem,
                    806,
                    @"[In Appendix C: Product Behavior] CopyItemSoapIn: For each item being copied that is a recurring calendar item, implementation does contain a RecurringMasterItemId child element ([MS-OXWSCORE] section 2.2.4.11). (Exchange 2007 and above follow this behavior.)");
            }
            #endregion

            #region Clean up organizer's drafts and calendar folders.
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.drafts
            });
            #endregion
        }
        public void MSOXWSMTGS_S04_TC04_MoveItemErrorCalendarCannotMoveOrCopyOccurrence()
        {
            #region Define a recurring calendar item
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            calendarItem.Start = startTime;
            calendarItem.StartSpecified = true;
            calendarItem.End = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified = true;
            calendarItem.Recurrence = new RecurrenceType();
            calendarItem.Recurrence.Item = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);

            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex = this.InstanceIndex;
            #endregion

            #region Copy one occurrence of the recurring calendar item
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.drafts;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            MoveItemType moveItemRequest = new MoveItemType();
            moveItemRequest.ItemIds = new BaseItemIdType[] { occurrenceItemId };
            moveItemRequest.ToFolderId = targetFolderId;
            MoveItemResponseType response = this.MTGSAdapter.MoveItem(moveItemRequest);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1228");

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1228
            Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                response.ResponseMessages.Items[0].ResponseClass,
                1228,
                @"[In Messages] If the request is unsuccessful, the MoveItem operation returns a MoveItemResponse element with the ResponseClass attribute of the MoveItemResponseMessage element set to ""Error"". ");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1231");

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1231
            Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorCalendarCannotMoveOrCopyOccurrence,
                response.ResponseMessages.Items[0].ResponseCode,
                1231,
                @"[In Messages] ErrorCalendarCannotMoveOrCopyOccurrence: Specifies that an attempt was made to move or copy an occurrence of a recurring calendar item.");
            #endregion

            #region Clean up organizer's calendar folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.calendar });
            #endregion
        }
        public void MSOXWSMTGS_S04_TC03_MoveRecurringCalendar()
        {
            #region Define a recurring calendar item to move
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            calendarItem.Start = startTime;
            calendarItem.StartSpecified = true;
            calendarItem.End = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified = true;
            calendarItem.Recurrence = new RecurrenceType();
            calendarItem.Recurrence.Item = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);
            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex = this.InstanceIndex;
            #endregion

            #region Get the Id of the occurrence item
            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId);
            Site.Assert.IsNotNull(getItem, "Organizer should get the occurrence item successfully.");

            RecurringMasterItemIdType recurringMasterItemId = new RecurringMasterItemIdType();
            recurringMasterItemId.ChangeKey = getItem.Items.Items[0].ItemId.ChangeKey;
            recurringMasterItemId.OccurrenceId = getItem.Items.Items[0].ItemId.Id;
            #endregion

            #region Move the recurring calendar item to Inbox folder
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            ItemInfoResponseMessageType movedItem = this.MoveSingleCalendarItem(Role.Organizer, recurringMasterItemId, targetFolderId);
            Site.Assert.IsNotNull(movedItem, @"Server should return success for moving the recurring calendar item.");
            #endregion

            #region Call FindItem to verify the recurring calendar item is moved to Inbox folder
            CalendarItemType calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.inbox, "IPM.Appointment", calendarItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The recurring calendar should be in organizer's inbox folder.");

            if (Common.IsRequirementEnabled(808, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R808");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R808
                this.Site.CaptureRequirementIfAreEqual<CalendarItemTypeType>(
                    CalendarItemTypeType.RecurringMaster,
                    calendar.CalendarItemType1,
                    808,
                    @"[In Appendix C: Product Behavior] MoveItemSoapIn: For each item being moved that is a recurring calendar item, implementation does contain a RecurringMasterItemId child element ([MS-OXWSCORE] section 2.2.4.11). (Exchange 2007 and above follow this behavior.)");
            }
            #endregion

            #region Clean up organizer's inbox folder.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox });
            #endregion
        }
        public void MSOXWSCORE_S07_TC17_GetTaskItemWithIconIndexSuccessfully()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1917, this.Site), "Exchange 2007 and Exchange 2010 do not support the IconIndex element.");

            #region Step 1: Create a recurring task item.
            // Define the pattern and range of the recurring task item.
            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = 1;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = 5;
            range.StartDate = System.DateTime.Now;

            // Define the TaskType item.
            TaskType[] items = new TaskType[] { new TaskType() };
            items[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            items[0].Recurrence = new TaskRecurrenceType();
            items[0].Recurrence.Item = pattern;
            items[0].Recurrence.Item1 = range;

            // Call CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.tasks, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            BaseItemIdType[] createdTaskItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

            // One created task item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 createdTaskItemIds.GetLength(0),
                 "One created task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 createdTaskItemIds.GetLength(0));
            #endregion

            #region Step 2: Get the recurring task item by ItemIdType.
            GetItemType getItem = new GetItemType();

            // Create item and return the item id.
            getItem.ItemIds = createdTaskItemIds;

            // Set the item shape's elements.
            getItem.ItemShape = new ItemResponseShapeType();
            getItem.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;
            getItem.ItemShape.AdditionalProperties = new PathToUnindexedFieldType[] { new PathToUnindexedFieldType() { FieldURI = UnindexedFieldURIType.itemIconIndex } };

            // Call GetItem operation using the created task item ID.
            GetItemResponseType getItemResponse = this.COREAdapter.GetItem(getItem);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
            #endregion

            #region Step 3: Assert the value of IconIndex element is "TaskRecur".
            TaskType[] taskItems = Common.GetItemsFromInfoResponse<TaskType>(getItemResponse);

            // One created item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 taskItems.GetLength(0),
                 "One item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 taskItems.GetLength(0));

            Site.Assert.IsTrue(this.IsSchemaValidated, "The schema should be validated.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1917");
        
            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1917
            this.Site.CaptureRequirementIfAreEqual<IconIndexType>(
                IconIndexType.TaskRecur,
                taskItems[0].IconIndex,
                1917,
                @"[In Appendix C: Product Behavior] Implementation does support value ""TaskRecur"" of ""IconIndex"" simple type which specifies the recurring task icon. (Exchange 2013 and above follow this behavior.)");
            #endregion
        }
        public void MSOXWSCORE_S07_TC17_GetTaskItemWithIconIndexSuccessfully()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1917, this.Site), "Exchange 2007 and Exchange 2010 do not support the IconIndex element.");

            #region Step 1: Create a recurring task item.
            // Define the pattern and range of the recurring task item.
            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = 1;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = 5;
            range.StartDate           = System.DateTime.Now;

            // Define the TaskType item.
            TaskType[] items = new TaskType[] { new TaskType() };
            items[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            items[0].Recurrence       = new TaskRecurrenceType();
            items[0].Recurrence.Item  = pattern;
            items[0].Recurrence.Item1 = range;

            // Call CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.tasks, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            BaseItemIdType[] createdTaskItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

            // One created task item should be returned.
            Site.Assert.AreEqual <int>(
                1,
                createdTaskItemIds.GetLength(0),
                "One created task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                1,
                createdTaskItemIds.GetLength(0));
            #endregion

            #region Step 2: Get the recurring task item by ItemIdType.
            GetItemType getItem = new GetItemType();

            // Create item and return the item id.
            getItem.ItemIds = createdTaskItemIds;

            // Set the item shape's elements.
            getItem.ItemShape                      = new ItemResponseShapeType();
            getItem.ItemShape.BaseShape            = DefaultShapeNamesType.AllProperties;
            getItem.ItemShape.AdditionalProperties = new PathToUnindexedFieldType[] { new PathToUnindexedFieldType()
                                                                                      {
                                                                                          FieldURI = UnindexedFieldURIType.itemIconIndex
                                                                                      } };

            // Call GetItem operation using the created task item ID.
            GetItemResponseType getItemResponse = this.COREAdapter.GetItem(getItem);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
            #endregion

            #region Step 3: Assert the value of IconIndex element is "TaskRecur".
            TaskType[] taskItems = Common.GetItemsFromInfoResponse <TaskType>(getItemResponse);

            // One created item should be returned.
            Site.Assert.AreEqual <int>(
                1,
                taskItems.GetLength(0),
                "One item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                1,
                taskItems.GetLength(0));

            Site.Assert.IsTrue(this.IsSchemaValidated, "The schema should be validated.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1917");

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1917
            this.Site.CaptureRequirementIfAreEqual <IconIndexType>(
                IconIndexType.TaskRecur,
                taskItems[0].IconIndex,
                1917,
                @"[In Appendix C: Product Behavior] Implementation does support value ""TaskRecur"" of ""IconIndex"" simple type which specifies the recurring task icon. (Exchange 2013 and above follow this behavior.)");
            #endregion
        }
        public void MSOXWSMTGS_S04_TC05_MoveItemErrorCalendarCannotUseIdForOccurrenceId()
        {
            #region Define a meeting
            int timeInterval             = this.TimeInterval;
            CalendarItemType meetingItem = new CalendarItemType();
            meetingItem.UID     = Guid.NewGuid().ToString();
            meetingItem.Subject = this.Subject;
            meetingItem.Start   = DateTime.UtcNow;

            meetingItem.StartSpecified = true;
            timeInterval++;
            meetingItem.End          = DateTime.Now.AddHours(timeInterval);
            meetingItem.EndSpecified = true;
            meetingItem.Location     = this.Location;

            meetingItem.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) };

            // Create the  meeting
            ItemInfoResponseMessageType itemInfo = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy);
            Site.Assert.IsNotNull(itemInfo, "Server should return success for creating a recurring meeting.");

            CalendarItemType calendarInOrganizer = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendarInOrganizer, "The meeting should be found in organizer's Calendar folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendToAllAndSaveCopy.");
            #endregion

            #region Define a recurring calendar item to move
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate           = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID              = Guid.NewGuid().ToString();
            calendarItem.Subject          = this.Subject;
            calendarItem.Start            = startTime;
            calendarItem.StartSpecified   = true;
            calendarItem.End              = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified     = true;
            calendarItem.Recurrence       = new RecurrenceType();
            calendarItem.Recurrence.Item  = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item             = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);
            OccurrenceItemIdType        occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey         = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex     = this.InstanceIndex;
            #endregion

            #region Get the Id of the occurrence item
            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId);
            Site.Assert.IsNotNull(getItem, "Organizer should get the occurrence item successfully.");

            RecurringMasterItemIdType recurringMasterItemId = new RecurringMasterItemIdType();
            recurringMasterItemId.ChangeKey    = getItem.Items.Items[0].ItemId.ChangeKey;
            recurringMasterItemId.OccurrenceId = calendarInOrganizer.ItemId.Id;
            #endregion

            #region Move the recurring calendar item to Inbox folder
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            MoveItemType moveItemRequest = new MoveItemType();
            moveItemRequest.ItemIds    = new BaseItemIdType[] { recurringMasterItemId };
            moveItemRequest.ToFolderId = targetFolderId;
            MoveItemResponseType response = this.MTGSAdapter.MoveItem(moveItemRequest);
            #endregion

            #region Capture code
            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1232");

            //Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1232
            Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.ErrorCalendarCannotUseIdForOccurrenceId,
                response.ResponseMessages.Items[0].ResponseCode,
                1232,
                @"[In Messages] ErrorCalendarCannotUseIdForOccurrenceId: Specifies that the OccurrenceId ([MS-OXWSCORE] section 2.2.4.39) does not correspond to a valid occurrence of a recurring master item.");
            #endregion

            #region Clean up organizer's calendar, sentitems and deleteditems folders and attendee's calendar, inbox and deleteditems folders.
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType> {
                DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems
            });
            this.CleanupFoldersByRole(Role.Attendee, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.deleteditems
            });
            #endregion
        }
        public void MSOXWSMTGS_S01_TC03_CreateRecurringMeetingAndDecline()
        {
            #region Organizer creates a recurring meeting with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll
            #region Define a recurring meeting
            int timeInterval = this.TimeInterval;
            DateTime startTime = DateTime.Now.AddHours(timeInterval);

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate = startTime;

            CalendarItemType meetingItem = new CalendarItemType();
            meetingItem.UID = Guid.NewGuid().ToString();
            meetingItem.Subject = this.Subject;
            meetingItem.Start = startTime;

            // Indicates the Start property is serialized in the SOAP message.
            meetingItem.StartSpecified = true;
            timeInterval++;
            meetingItem.End = startTime.AddHours(timeInterval);
            meetingItem.EndSpecified = true;
            meetingItem.Location = this.Location;
            meetingItem.Recurrence = new RecurrenceType();
            meetingItem.Recurrence.Item = pattern;
            meetingItem.Recurrence.Item1 = range;
            meetingItem.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) };
            meetingItem.OptionalAttendees = new AttendeeType[] { GetAttendeeOrResource(this.OrganizerEmailAddress) };
            meetingItem.Resources = new AttendeeType[] { GetAttendeeOrResource(this.RoomEmailAddress) };

            if (Common.IsRequirementEnabled(715, this.Site))
            {
                meetingItem.MeetingTimeZone = new TimeZoneType();
                meetingItem.MeetingTimeZone.BaseOffset = "PT7H";
                meetingItem.MeetingTimeZone.Standard = new TimeChangeType();
                meetingItem.MeetingTimeZone.Standard.Offset = "PT0H";
                meetingItem.MeetingTimeZone.Standard.Time = DateTime.Now;
                RelativeYearlyRecurrencePatternType yearlyRecurrence = new RelativeYearlyRecurrencePatternType();
                yearlyRecurrence.DaysOfWeek = "Sunday";
                yearlyRecurrence.DayOfWeekIndex = DayOfWeekIndexType.First;
                yearlyRecurrence.Month = MonthNamesType.November;
                meetingItem.MeetingTimeZone.Standard.Item = yearlyRecurrence;
                meetingItem.MeetingTimeZone.Daylight = new TimeChangeType();
                meetingItem.MeetingTimeZone.Daylight.Offset = "-PT1H";
                yearlyRecurrence = new RelativeYearlyRecurrencePatternType();
                yearlyRecurrence.DaysOfWeek = "Sunday";
                yearlyRecurrence.DayOfWeekIndex = DayOfWeekIndexType.Second;
                yearlyRecurrence.Month = MonthNamesType.March;
                meetingItem.MeetingTimeZone.Daylight.Item = yearlyRecurrence;
                meetingItem.MeetingTimeZone.Daylight.Time = DateTime.Now;
                meetingItem.MeetingTimeZone.TimeZoneName = "Time Zone";
            }
            #endregion

            // Create the recurring meeting
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(item, "Server should return success for creating a recurring meeting.");
            ItemIdType meetingId = item.Items.Items[0].ItemId;

            #region Verify FirstOccurrence and LastOccurrence in the CalendarItemType
            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, meetingId);
            Site.Assert.IsNotNull(getItem, "The calendar item to be deleted should exist.");

            if (Common.IsRequirementEnabled(715, this.Site))
            {
                CalendarItemType calendar = (CalendarItemType)getItem.Items.Items[0];

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R715");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R715
                this.Site.CaptureRequirementIfIsNotNull(
                    calendar.MeetingTimeZone,
                    715,
                    @"[In Appendix C: Product Behavior] Implementation does support complex type ""MeetingTimeZone"" with type ""t:TimeZoneType (section 2.2.4.40)"" which does specify the time zone of the location where the meeting is hosted. (<28> Section 2.2.4.9: Only Exchange 2007 supports the MeetingTimeZone element.)");
                
                if (Common.IsRequirementEnabled(654, this.Site))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R654");

                    // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R654
                    this.Site.CaptureRequirementIfIsNotNull(
                        calendar.MeetingTimeZone,
                        654,
                        @"[In Appendix C: Product Behavior] Implementation does support the TimeZoneType complex type. (<17> Section 2.2.4: Only Exchange 2007 supports the TimeZoneType complex type.)");
                }

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1053");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1053
                this.Site.CaptureRequirementIfIsNotNull(
                    calendar.MeetingTimeZone,
                    1053,
                    @"[In t:CalendarItemType Complex Type] This element [MeetingTimeZone] is returned only if the value of the CalendarItemType element is RecurringMaster.");

                TimeZoneType timeZone = calendar.MeetingTimeZone;

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R407");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R407
                this.Site.CaptureRequirementIfIsNotNull(
                    timeZone.BaseOffset,
                    407,
                    @"[In t:TimeZoneType Complex Type] BaseOffset: Specifies the hourly offset from Coordinated Universal Time (UTC) for the current time zone.");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R409");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R409
                this.Site.CaptureRequirementIfIsNotNull(
                    timeZone.Standard,
                    409,
                    @"[In t:TimeZoneType Complex Type] Standard: Specifies the date and time when the time changes from daylight saving time to standard time.");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R411");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R411
                this.Site.CaptureRequirementIfIsNotNull(
                    timeZone.Daylight,
                    411,
                    @"[In t:TimeZoneType Complex Type] Daylight: Specifies the date and time when the time changes from standard time to daylight saving time.");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R585");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R585
                this.Site.CaptureRequirementIfIsNotNull(
                    timeZone.TimeZoneName,
                    585,
                    @"[In t:TimeZoneType Complex Type] TimeZoneName: Specifies the time zone name.");

                TimeChangeType timeChange = timeZone.Standard;

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R399");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R399
                this.Site.CaptureRequirementIfIsNotNull(
                    timeChange.Offset,
                    399,
                    @"[In t:TimeChangeType Complex Type] Offset: Specifies the offset from the duration specified by the BaseOffset element (section 2.2.4.24).");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R401");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R401
                this.Site.CaptureRequirementIfIsNotNull(
                    timeChange.Time,
                    401,
                    @"[In t:TimeChangeType Complex Type] Time: Specifies the time when the time changes between standard time and daylight saving time.");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R403");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R403
                this.Site.CaptureRequirementIfIsNotNull(
                    timeChange.TimeZoneName,
                    403,
                    @"[In t:TimeChangeType Complex Type] TimeZoneName: Specifies the time zone name.");
            }

            string actualFirstOccurrenceId = ((CalendarItemType)getItem.Items.Items[0]).FirstOccurrence.ItemId.Id;
            string actualLastOccurrenceId = ((CalendarItemType)getItem.Items.Items[0]).LastOccurrence.ItemId.Id;

            // Get the first occurrence by item id
            OccurrenceItemIdType firstOccurrenceId = new OccurrenceItemIdType();
            firstOccurrenceId.ChangeKey = meetingId.ChangeKey;
            firstOccurrenceId.RecurringMasterId = meetingId.Id;
            firstOccurrenceId.InstanceIndex = 1;

            getItem = this.GetSingleCalendarItem(Role.Organizer, firstOccurrenceId);
            Site.Assert.IsNotNull(getItem, "The first occurrence should be found.");
            CalendarItemType firstOccurrence = getItem.Items.Items[0] as CalendarItemType;

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R213");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R213
            this.Site.CaptureRequirementIfAreEqual<string>(
                firstOccurrence.ItemId.Id,
                actualFirstOccurrenceId,
                213,
                "[In t:CalendarItemType Complex Type]FirstOccurrence: Specifies the first occurrence of a recurring calendar item.");

            // Get the last occurrence by item id
            OccurrenceItemIdType lastOccurrenceId = new OccurrenceItemIdType();
            lastOccurrenceId.ChangeKey = meetingId.ChangeKey;
            lastOccurrenceId.RecurringMasterId = meetingId.Id;
            lastOccurrenceId.InstanceIndex = this.NumberOfOccurrences;

            getItem = this.GetSingleCalendarItem(Role.Organizer, lastOccurrenceId);
            Site.Assert.IsNotNull(getItem, "The last occurrence should be found.");
            CalendarItemType lastOccurrence = getItem.Items.Items[0] as CalendarItemType;

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R215");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R215
            this.Site.CaptureRequirementIfAreEqual<string>(
                lastOccurrence.ItemId.Id,
                actualLastOccurrenceId,
                215,
                "[In t:CalendarItemType Complex Type]LastOccurrence: Specifies the last occurrence of a recurring calendar item.");
            #endregion
            #endregion

            #region Organizer deletes an occurrence of the recurring calendar item with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll
            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey = meetingId.ChangeKey;
            occurrenceItemId.RecurringMasterId = meetingId.Id;
            occurrenceItemId.InstanceIndex = this.InstanceIndex;

            getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId);
            Site.Assert.IsNotNull(getItem, "The calendar item to be deleted should exist.");

            ResponseMessageType deletedItem = this.DeleteSingleCalendarItem(Role.Organizer, occurrenceItemId, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(deletedItem, "The occurrence of the recurring calendar item should be deleted.");
            #endregion

            #region Attendee calls CreateItem to decline the meeting request with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll
            MeetingRequestMessageType request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType;
            Site.Assert.IsNotNull(request, "Attendee should receive the meeting request message in the Inbox folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendOnlyToAll.");

            bool isFirstOccurrence = (firstOccurrence.Start == request.FirstOccurrence.Start) && (firstOccurrence.End == request.FirstOccurrence.End);

            if (Common.IsRequirementEnabled(715, this.Site)
                && Common.IsRequirementEnabled(706, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R706");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R706
                this.Site.CaptureRequirementIfIsNotNull(
                    request.MeetingTimeZone,
                    706,
                    @"[In Appendix C: Product Behavior] Implementation does support the complex type ""MeetingTimeZone"" with type ""t:TimeZoneType (section 2.2.4.24)"" which does specify the time zone of the location where the meeting is hosted. (<52> Section 2.2.4.22:  Only Exchange 2007 supports the MeetingTimeZone element.)");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1090");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1090
                this.Site.CaptureRequirementIfIsNotNull(
                    request.MeetingTimeZone,
                    1090,
                    @"[In t:MeetingRequestMessageType Complex Type] This element [MeetingTimeZone] is returned only if the value of the CalendarItemType element is RecurringMaster.");
            }

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R341, expected value of Start of first occurrence is {0} and actual value is {1}; expected value of End of first occurrence is {2} and actual value is {3}", firstOccurrence.Start, request.FirstOccurrence.Start, firstOccurrence.End, request.FirstOccurrence.End);

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R341
            this.Site.CaptureRequirementIfIsTrue(
                isFirstOccurrence,
                341,
                "[In t:MeetingRequestMessageType Complex Type] FirstOccurrence: Represents the first occurrence of a recurring meeting item.");

            bool isLastOccurrence = (lastOccurrence.Start == request.LastOccurrence.Start) && (lastOccurrence.End == request.LastOccurrence.End);

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R343, expected value of Start of last occurrence is {0} and actual value is {1}; expected value of End of last occurrence is {2} and actual value is {3}", lastOccurrence.Start, request.LastOccurrence.Start, lastOccurrence.End, request.LastOccurrence.End);

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R343
            this.Site.CaptureRequirementIfIsTrue(
                isLastOccurrence,
                343,
                "[In t:MeetingRequestMessageType Complex Type] LastOccurrence: Represents the last occurrence of a recurring meeting item.");

            DeclineItemType declinedItem = new DeclineItemType();
            declinedItem.ReferenceItemId = new ItemIdType();
            declinedItem.ReferenceItemId.Id = request.ItemId.Id;

            item = this.CreateSingleCalendarItem(Role.Attendee, declinedItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(item, "Decline meeting request should be successful.");
            #endregion

            #region Organizer calls CreateItem with MeetingCancellationMessageType to cancel the created meeting with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll
            MeetingResponseMessageType response = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Resp", meetingItem.UID) as MeetingResponseMessageType;
            Site.Assert.IsNotNull(response, "The decline response should be in the Inbox folder.");
            CancelCalendarItemType cancelCalendarItem = new CancelCalendarItemType();
            cancelCalendarItem.ReferenceItemId = response.AssociatedCalendarItemId;

            item = this.CreateSingleCalendarItem(Role.Organizer, cancelCalendarItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(item, "Cancel the meeting through CancelCalendarItemType using CreateItem should be successful.");
            #endregion

            #region Attendee finds the meeting cancellation message from his Inbox folder
            MeetingCancellationMessageType canceledMeeting = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Canceled", meetingItem.UID) as MeetingCancellationMessageType;
            Site.Assert.IsNotNull(canceledMeeting, "The canceled meeting should be in the Inbox folder.");
            #endregion

            #region Clean up organizer's inbox, sentitems and deleteditems folders, and attendee's inbox, sentitems and deleteditems folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems });
            this.CleanupFoldersByRole(Role.Attendee, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems });
            #endregion
        }
        public void MSOXWSMTGS_S01_TC21_DeleteItemErrorSendMeetingCancellationsRequired()
        {
            #region Define a recurring calendar item
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            calendarItem.Start = startTime;
            calendarItem.StartSpecified = true;
            calendarItem.End = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified = true;
            calendarItem.Recurrence = new RecurrenceType();
            calendarItem.Recurrence.Item = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);

            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex = this.InstanceIndex;
            #endregion

            #region Get the targeted occurrence item
            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId);
            Site.Assert.IsNotNull(getItem, @"Get the occurrence should be successful.");

            RecurringMasterItemIdType invalidRecurringMasterItemId = new RecurringMasterItemIdType();
            invalidRecurringMasterItemId.ChangeKey = getItem.Items.Items[0].ItemId.ChangeKey;
            invalidRecurringMasterItemId.OccurrenceId = getItem.Items.Items[0].ItemId.Id;
            #endregion

            #region Delete the occurrence
            DeleteItemType deleteItemRequest = new DeleteItemType();
            deleteItemRequest.ItemIds = new BaseItemIdType[] { occurrenceItemId };
            deleteItemRequest.DeleteType = DisposalType.HardDelete;
            DeleteItemResponseType deleteItemResponse = this.MTGSAdapter.DeleteItem(deleteItemRequest);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1209");

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1209
            Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                deleteItemResponse.ResponseMessages.Items[0].ResponseClass,
                1209,
                @"[In Messages] If the request is unsuccessful, the DeleteItem operation returns a DeleteItemResponse element with the ResponseClass attribute of the DeleteItemResponseMessage element set to ""Error"". ");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1213");

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1213
            Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorSendMeetingCancellationsRequired,
                deleteItemResponse.ResponseMessages.Items[0].ResponseCode,
                1213,
                @"[In Messages] ErrorSendMeetingCancellationsRequired: Occurs during a DeleteItem call, when the SendMeetingCancellations property is missing from the request and the item to delete is a calendar item. ");
            #endregion

            #region Clean up organizer's calendar folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.calendar });
            #endregion
        }
        public void MSOXWSMTGS_S01_TC17_UpdateAndDeleteoccurrenceOfRecurringMeeting()
        {
            #region Organizer creates a recurring meeting
            // Verify DailyRecurrencePatternType and NumberedRecurrenceRangeType.
            DailyRecurrencePatternType dailyPattern = new DailyRecurrencePatternType();
            NumberedRecurrenceRangeType numberedRange = new NumberedRecurrenceRangeType();
            numberedRange.NumberOfOccurrences = this.NumberOfOccurrences;

            // Define a recurring meeting.
            CalendarItemType meetingItem = this.DefineRecurringMeeting(dailyPattern, numberedRange);
            Site.Assert.IsNotNull(meetingItem, "The meeting item should be created.");

            // Create the recurring meeting.
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(item, "The recurring meeting should be created successfully.");
            #endregion

            #region Attendee gets the meeting request
            MeetingRequestMessageType request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType;
            Site.Assert.IsNotNull(request, "The meeting request message should be found in attendee's Inbox folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendOnlyToAll.");
            #endregion

            #region Attendee accepts the meeting request
            AcceptItemType acceptItem = new AcceptItemType();
            acceptItem.ReferenceItemId = new ItemIdType();
            acceptItem.ReferenceItemId.Id = request.ItemId.Id;
            item = this.CreateSingleCalendarItem(Role.Attendee, acceptItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(item, "Accept the meeting request should be successful.");
            #endregion

            #region Attendee gets the accepted meeting request.
            request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.deleteditems, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType;
            Site.Assert.IsNotNull(request, "The meeting request should exist in attendee's Deleted Items folder after attendee accepts the meeting request.");
            Site.Assert.IsTrue(request.IsOutOfDateSpecified, "Element IsOutOfDate should be present.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R751");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R751
            this.Site.CaptureRequirementIfIsFalse(
                request.IsOutOfDate,
                751,
                @"[In t:MeetingMessageType Complex Type] otherwise [ there has not been an update to the meeting and the current item in the calendar is not out of date] false.");
            #endregion

            #region Organizer gets the calendar item
            CalendarItemType calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(item, "The calendar item should be found in organizer's Calendar folder.");
            #endregion

            #region Organizer deletes one of the occurrences of the recurring meeting
            OccurrenceItemIdType occurrenceId = new OccurrenceItemIdType();
            occurrenceId.RecurringMasterId = calendar.ItemId.Id;
            occurrenceId.InstanceIndex = 1;

            DeleteItemType deleteItemRequest = new DeleteItemType();
            deleteItemRequest.ItemIds = new BaseItemIdType[] { occurrenceId };
            deleteItemRequest.DeleteType = DisposalType.HardDelete;
            deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendOnlyToAll;
            deleteItemRequest.SendMeetingCancellationsSpecified = true;
            DeleteItemResponseType deleteItemResponse = this.MTGSAdapter.DeleteItem(deleteItemRequest);
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);

            calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The calendar item should exist.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1214");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1214
            // SendMeetingCancellationsSpecified is specified as true, and the occurrence is deleted successfully, this requirement can be captured.
            this.Site.CaptureRequirement(
                1214,
                @"[In Messages] If you are using the proxy objects, make sure that the SendMeetingCancellationsSpecified property is set to true.");
            #endregion

            #region Organizer updates one of the occurrences of the recurring meeting
            occurrenceId = new OccurrenceItemIdType();
            occurrenceId.RecurringMasterId = calendar.ItemId.Id;
            occurrenceId.ChangeKey = calendar.ItemId.ChangeKey;
            occurrenceId.InstanceIndex = 2;
            UpdateItemType updateItemRequest = new UpdateItemType();
            updateItemRequest.ItemChanges = new ItemChangeType[1];
            updateItemRequest.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToAllAndSaveCopy;
            updateItemRequest.SendMeetingInvitationsOrCancellationsSpecified = true;
            updateItemRequest.MessageDisposition = MessageDispositionType.SendAndSaveCopy;
            updateItemRequest.MessageDispositionSpecified = true;
            updateItemRequest.ConflictResolution = ConflictResolutionType.AlwaysOverwrite;
            updateItemRequest.ItemChanges[0] = new ItemChangeType();
            updateItemRequest.ItemChanges[0].Item = occurrenceId;
            SetItemFieldType setItemField = new SetItemFieldType();
            PathToUnindexedFieldType pathToUnindexed = new PathToUnindexedFieldType();
            pathToUnindexed.FieldURI = UnindexedFieldURIType.calendarLocation;
            setItemField.Item = pathToUnindexed;
            setItemField.Item1 = new CalendarItemType() { Location = this.LocationUpdate };
            updateItemRequest.ItemChanges[0].Updates = new ItemChangeDescriptionType[] { setItemField };
            UpdateItemResponseType updateItemResponse = this.MTGSAdapter.UpdateItem(updateItemRequest);
            Common.CheckOperationSuccess(updateItemResponse, 1, this.Site);
            #endregion

            #region Organizer gets the udpated calendar item
            calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            #endregion

            #region Organizer updates the calendar item
            updateItemRequest.ItemChanges[0].Item = calendar.ItemId;
            string locationUpdated = Common.GenerateResourceName(this.Site, "NewLocation");
            setItemField.Item1 = new CalendarItemType() { Location = locationUpdated };
            updateItemRequest.ItemChanges[0].Updates = new ItemChangeDescriptionType[] { setItemField };

            updateItemResponse = this.MTGSAdapter.UpdateItem(updateItemRequest);
            Common.CheckOperationSuccess(updateItemResponse, 1, this.Site);
            #endregion

            #region Attendee gets the updated meeting request
            request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, locationUpdated, meetingItem.UID, UnindexedFieldURIType.calendarLocation) as MeetingRequestMessageType;

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R345");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R345
            this.Site.CaptureRequirementIfAreEqual<int>(
                1,
                request.ModifiedOccurrences.Length,
                345,
                @"[In t:MeetingRequestMessageType Complex Type] ModifiedOccurrences: Contains an array of recurring meeting item occurrences that have been modified so that they are different from the original instances of the recurrence master item.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R347");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R347
            this.Site.CaptureRequirementIfAreEqual<int>(
                1,
                request.DeletedOccurrences.Length,
                347,
                @"[In t:MeetingRequestMessageType Complex Type] DeletedOccurrences: Contains an array of deleted occurrences of a recurring meeting item.");
            #endregion

            #region Attendee gets the accepted meeting request again.
            request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.deleteditems, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType;
            Site.Assert.IsNotNull(request, "The meeting request should exist in attendee's Deleted Items folder after attendee accepts the meeting request.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R750");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R750
            this.Site.CaptureRequirementIfIsTrue(
                request.IsOutOfDate,
                750,
                @"[In t:MeetingMessageType Complex Type] [IsOutOfDate is] True,  there has been an update to the meeting and the current item in the calendar is out of date.");
            #endregion

            #region Clean up organizer's deleteditems and sentitems folder, and attendee's inbox, calendar and deleteditems folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems });
            this.CleanupFoldersByRole(Role.Attendee, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.deleteditems });
            #endregion
        }
        public void MSOXWSMTGS_S01_TC16_DeleteOccurrenceOfRecurringMeeting()
        {
            #region Organizer creates a recurring meeting
            // Verify DailyRecurrencePatternType and NumberedRecurrenceRangeType.
            DailyRecurrencePatternType dailyPattern = new DailyRecurrencePatternType();
            NumberedRecurrenceRangeType numberedRange = new NumberedRecurrenceRangeType();
            numberedRange.NumberOfOccurrences = this.NumberOfOccurrences;

            // Define a recurring meeting.
            CalendarItemType meetingItem = this.DefineRecurringMeeting(dailyPattern, numberedRange);
            Site.Assert.IsNotNull(meetingItem, "The meeting item should be created.");

            // Create the recurring meeting.
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy);
            Site.Assert.IsNotNull(item, "The recurring meeting should be created successfully.");
            #endregion

            #region Attendee gets and verifies the recurring meeting request
            CalendarItemType calendar = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The meeting should exist in the attendee's Calendar folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendOnlyToAll.");
            #endregion

            #region Organizer deletes one of the occurrences of the recurring meeting
            // Get the occurrence to be deleted.
            ItemType occurrence = this.GetFirstOccurrenceItem(meetingItem, Role.Organizer);
            Site.Assert.IsNotNull(occurrence, "The specified occurrence item should be found.");

            // Store the start and end time of the occurrence to be deleted.
            CalendarItemType occurrenceItem = occurrence as CalendarItemType;

            // Delete the occurrence.
            bool isDeleted = this.DeleteOccurrenceItem(occurrence.ItemId);
            Site.Assert.IsTrue(isDeleted, "The occurrence item should be deleted.");

            calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The calendar item should exist.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R219");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R219
            this.Site.CaptureRequirementIfIsNotNull(
                calendar.DeletedOccurrences,
                219,
                @"[In t:CalendarItemType Complex Type]DeletedOccurrences: Specifies deleted occurrences of a recurring calendar item.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R373");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R373
            this.Site.CaptureRequirementIfAreEqual<DateTime>(
                occurrenceItem.Start,
                calendar.DeletedOccurrences[0].Start,
                373,
                @"[In t:NonEmptyArrayOfDeletedOccurrencesType Complex Type] DeletedOccurrence: Represents a deleted occurrence of a recurring calendar item.");
            #endregion

            #region Organizer deletes the recurring meeting
            MeetingRequestMessageType meetingRequest = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.sentitems, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType;

            CalendarItemType recurringCalendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(recurringCalendar, "The meeting should exist in the organizer's calendar folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendOnlyToAll.");

            ResponseMessageType deletedItem = this.DeleteSingleCalendarItem(Role.Organizer, recurringCalendar.ItemId, CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy);

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R620");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R620
            this.Site.CaptureRequirementIfIsNotNull(
                deletedItem,
                620,
                @"[In Messages] DeleteItemSoapIn: For each item being deleted that is a recurring calendar item, the ItemIds element can contain a RecurringMasterItemId child element ([MS-OXWSCORE] section 2.2.4.11) or an OccurrenceItemId child element ([MS-OXWSCORE] section 2.2.4.11).");
            #endregion

            #region Clean up organizer's deleteditems and sentitems folder, and attendee's inbox, calendar and deleteditems folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems });
            this.CleanupFoldersByRole(Role.Attendee, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.deleteditems });
            #endregion
        }
 public void MSOXWSMTGS_S01_TC10_ModifyOccurrenceWithDailyPatternAndNumberedRange()
 {
     // Verify DailyRecurrencePatternType and NumberedRecurrenceRangeType.
     DailyRecurrencePatternType dailyPattern = new DailyRecurrencePatternType();
     NumberedRecurrenceRangeType numberedRange = new NumberedRecurrenceRangeType();
     numberedRange.NumberOfOccurrences = this.NumberOfOccurrences;
     this.VerifyModifiedOccurrences(dailyPattern, numberedRange);
 }
        public void MSOXWSMTGS_S03_TC05_CopyItemErrorCalendarCannotUseIdForRecurringMasterId()
        {
            #region Define a meeting
            int timeInterval = this.TimeInterval;
            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID     = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            calendarItem.Start   = DateTime.UtcNow;

            calendarItem.StartSpecified = true;
            timeInterval++;
            calendarItem.End          = DateTime.Now.AddHours(timeInterval);
            calendarItem.EndSpecified = true;
            calendarItem.Location     = this.Location;

            calendarItem.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) };

            ItemInfoResponseMessageType item1 = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy);
            Site.Assert.IsNotNull(item1, "Server should return success for creating a recurring meeting.");

            CalendarItemType calendarInOrganizer = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", calendarItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendarInOrganizer, "The meeting should be found in organizer's Calendar folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendToAllAndSaveCopy.");

            #endregion

            #region Define a recurring calendar item
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate           = startTime;

            CalendarItemType meetingItem = new CalendarItemType();
            meetingItem.UID               = Guid.NewGuid().ToString();
            meetingItem.Subject           = this.Subject;
            meetingItem.Start             = startTime;
            meetingItem.StartSpecified    = true;
            meetingItem.End               = startTime.AddHours(this.TimeInterval);
            meetingItem.EndSpecified      = true;
            meetingItem.Location          = this.Location;
            meetingItem.Recurrence        = new RecurrenceType();
            meetingItem.Recurrence.Item   = pattern;
            meetingItem.Recurrence.Item1  = range;
            meetingItem.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) };
            meetingItem.OptionalAttendees = new AttendeeType[] { GetAttendeeOrResource(this.OrganizerEmailAddress) };
            meetingItem.Resources         = new AttendeeType[] { GetAttendeeOrResource(this.RoomEmailAddress) };
            #endregion

            #region Organizer creates a recurring calendar item with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items       = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { meetingItem };
            createItemRequest.MessageDispositionSpecified     = true;
            createItemRequest.MessageDisposition              = MessageDispositionType.SaveOnly;
            createItemRequest.SendMeetingInvitationsSpecified = true;
            createItemRequest.SendMeetingInvitations          = CalendarItemCreateOrDeleteOperationType.SendToNone;

            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            #endregion

            #region Organizer copys the RecurringMasterId of the recurring calendar item

            #region Copy the recurring calendar item to Drafts folder through Id of recurring master getItem
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.drafts;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;
            OccurrenceItemIdType occurrenceId = new OccurrenceItemIdType();
            occurrenceId.RecurringMasterId = calendarInOrganizer.ItemId.Id;
            occurrenceId.InstanceIndex     = 1;

            CopyItemType copyItemRequest = new CopyItemType();
            copyItemRequest.ItemIds    = new BaseItemIdType[] { occurrenceId };
            copyItemRequest.ToFolderId = targetFolderId;
            CopyItemResponseType response = this.MTGSAdapter.CopyItem(copyItemRequest);

            #endregion

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1223");

            //Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1223
            Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.ErrorCalendarCannotUseIdForRecurringMasterId,
                response.ResponseMessages.Items[0].ResponseCode,
                1223,
                @"[In Messages] ErrorCalendarCannotUseIdForRecurringMasterId: Specifies that the RecurringMasterId ([MS-OXWSCORE] section 2.2.4.35) does not correspond to a valid recurring master item.");
            #endregion

            #region Clean up organizer's calendar, sentitems and deleteditems folders and attendee's calendar, inbox and deleteditems folders.
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType> {
                DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems
            });
            this.CleanupFoldersByRole(Role.Attendee, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.deleteditems
            });
            #endregion
        }
        public void MSOXWSMTGS_S04_TC03_MoveRecurringCalendar()
        {
            #region Define a recurring calendar item to move
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate           = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID              = Guid.NewGuid().ToString();
            calendarItem.Subject          = this.Subject;
            calendarItem.Start            = startTime;
            calendarItem.StartSpecified   = true;
            calendarItem.End              = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified     = true;
            calendarItem.Recurrence       = new RecurrenceType();
            calendarItem.Recurrence.Item  = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item             = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);
            OccurrenceItemIdType        occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey         = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex     = this.InstanceIndex;
            #endregion

            #region Get the Id of the occurrence item
            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId);
            Site.Assert.IsNotNull(getItem, "Organizer should get the occurrence item successfully.");

            RecurringMasterItemIdType recurringMasterItemId = new RecurringMasterItemIdType();
            recurringMasterItemId.ChangeKey    = getItem.Items.Items[0].ItemId.ChangeKey;
            recurringMasterItemId.OccurrenceId = getItem.Items.Items[0].ItemId.Id;
            #endregion

            #region Move the recurring calendar item to Inbox folder
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            ItemInfoResponseMessageType movedItem = this.MoveSingleCalendarItem(Role.Organizer, recurringMasterItemId, targetFolderId);
            Site.Assert.IsNotNull(movedItem, @"Server should return success for moving the recurring calendar item.");
            #endregion

            #region Call FindItem to verify the recurring calendar item is moved to Inbox folder
            CalendarItemType calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.inbox, "IPM.Appointment", calendarItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The recurring calendar should be in organizer's inbox folder.");

            if (Common.IsRequirementEnabled(808, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R808");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R808
                this.Site.CaptureRequirementIfAreEqual <CalendarItemTypeType>(
                    CalendarItemTypeType.RecurringMaster,
                    calendar.CalendarItemType1,
                    808,
                    @"[In Appendix C: Product Behavior] MoveItemSoapIn: For each item being moved that is a recurring calendar item, implementation does contain a RecurringMasterItemId child element ([MS-OXWSCORE] section 2.2.4.11). (Exchange 2007 and above follow this behavior.)");
            }
            #endregion

            #region Clean up organizer's inbox folder.
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.inbox
            });
            #endregion
        }
        public void MSOXWSMTGS_S04_TC04_MoveItemErrorCalendarCannotMoveOrCopyOccurrence()
        {
            #region Define a recurring calendar item
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate           = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID              = Guid.NewGuid().ToString();
            calendarItem.Subject          = this.Subject;
            calendarItem.Start            = startTime;
            calendarItem.StartSpecified   = true;
            calendarItem.End              = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified     = true;
            calendarItem.Recurrence       = new RecurrenceType();
            calendarItem.Recurrence.Item  = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);

            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey         = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex     = this.InstanceIndex;
            #endregion

            #region Copy one occurrence of the recurring calendar item
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.drafts;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            MoveItemType moveItemRequest = new MoveItemType();
            moveItemRequest.ItemIds    = new BaseItemIdType[] { occurrenceItemId };
            moveItemRequest.ToFolderId = targetFolderId;
            MoveItemResponseType response = this.MTGSAdapter.MoveItem(moveItemRequest);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1228");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1228
            Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Error,
                response.ResponseMessages.Items[0].ResponseClass,
                1228,
                @"[In Messages] If the request is unsuccessful, the MoveItem operation returns a MoveItemResponse element with the ResponseClass attribute of the MoveItemResponseMessage element set to ""Error"". ");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1231");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1231
            Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.ErrorCalendarCannotMoveOrCopyOccurrence,
                response.ResponseMessages.Items[0].ResponseCode,
                1231,
                @"[In Messages] ErrorCalendarCannotMoveOrCopyOccurrence: Specifies that an attempt was made to move or copy an occurrence of a recurring calendar item.");
            #endregion

            #region Clean up organizer's calendar folders.
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.calendar
            });
            #endregion
        }
        /// <summary>
        /// Create and get a recurring calendar item.
        /// </summary>
        /// <param name="start">The start time of a recurring calendar item</param>
        /// <param name="numberOfOccurrences">The number of occurrences of a recurring calendar item</param>
        /// <returns>The created recurring calendar item</returns>
        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 
        }
        public void MSOXWSCORE_S07_TC16_GetTaskItemWithTwoItemIdTypesSuccessfully()
        {
            #region Step 1: Create a recurring task item.
            // Define the pattern and range of the recurring task item.
            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = 1;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            int numberOfOccurrences           = 5;
            range.NumberOfOccurrences = numberOfOccurrences;
            System.DateTime start = System.DateTime.Now;
            range.StartDate = start;

            // Define the TaskType item.
            TaskType[] items = new TaskType[] { new TaskType() };
            items[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            items[0].Recurrence       = new TaskRecurrenceType();
            items[0].Recurrence.Item  = pattern;
            items[0].Recurrence.Item1 = range;

            // Call CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.tasks, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            BaseItemIdType[] createdTaskItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

            // One created task item should be returned.
            Site.Assert.AreEqual <int>(
                1,
                createdTaskItemIds.GetLength(0),
                "One created task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                1,
                createdTaskItemIds.GetLength(0));
            #endregion

            #region Step 2: Get the recurring task item by ItemIdType.
            // Call GetItem operation using the created task item ID.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(createdTaskItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
            #endregion

            // Exchange 2007 and Exchange 2010 do not support the RecurringMasterItemIdRanges element.
            SutVersion currentSutVersion = (SutVersion)Enum.Parse(typeof(SutVersion), Common.GetConfigurationPropertyValue("SutVersion", this.Site));
            if (currentSutVersion.Equals(SutVersion.ExchangeServer2013))
            {
                #region Step 3: Get the recurring task item by RecurringMasterItemIdRangesType.
                // Define the RecurringMasterItemIdRanges using the created task item ID.
                RecurringMasterItemIdRangesType[] recurringMasterItemIdRanges = new RecurringMasterItemIdRangesType[1];
                recurringMasterItemIdRanges[0]           = new RecurringMasterItemIdRangesType();
                recurringMasterItemIdRanges[0].Id        = (createdTaskItemIds[0] as ItemIdType).Id;
                recurringMasterItemIdRanges[0].ChangeKey = (createdTaskItemIds[0] as ItemIdType).ChangeKey;
                recurringMasterItemIdRanges[0].Ranges    = new OccurrencesRangeType[1];
                recurringMasterItemIdRanges[0].Ranges[0] = new OccurrencesRangeType();
                recurringMasterItemIdRanges[0].Ranges[0].CompareOriginalStartTimeSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].CompareOriginalStartTime          = true;
                recurringMasterItemIdRanges[0].Ranges[0].StartSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].Start          = start;
                recurringMasterItemIdRanges[0].Ranges[0].EndSpecified   = true;
                recurringMasterItemIdRanges[0].Ranges[0].End            = start.AddDays(numberOfOccurrences);

                // Call GetItem operation using the recurringMasterItemIdRanges.
                getItemResponse = this.CallGetItemOperation(recurringMasterItemIdRanges);

                // Check the operation response.
                Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
                #endregion
            }
        }
        public void MSOXWSMTGS_S03_TC03_CopyRecurringCalendar()
        {
            #region Define a recurring calendar item
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate = startTime;

            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            calendarItem.Start = startTime;
            calendarItem.StartSpecified = true;
            calendarItem.End = startTime.AddHours(this.TimeInterval);
            calendarItem.EndSpecified = true;
            calendarItem.Recurrence = new RecurrenceType();
            calendarItem.Recurrence.Item = pattern;
            calendarItem.Recurrence.Item1 = range;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);

            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();
            occurrenceItemId.ChangeKey = item.Items.Items[0].ItemId.ChangeKey;
            occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id;
            occurrenceItemId.InstanceIndex = this.InstanceIndex;
            #endregion

            #region Get the targeted occurrence item
            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId);
            Site.Assert.IsNotNull(getItem, @"Get the occurrence should be successful.");

            RecurringMasterItemIdType recurringMasterItemId = new RecurringMasterItemIdType();
            recurringMasterItemId.ChangeKey = getItem.Items.Items[0].ItemId.ChangeKey;
            recurringMasterItemId.OccurrenceId = getItem.Items.Items[0].ItemId.Id;
            #endregion

            #region Copy the recurring calendar item to Drafts folder through Id of recurring master getItem
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.drafts;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            ItemInfoResponseMessageType copiedItem = this.CopySingleCalendarItem(Role.Organizer, recurringMasterItemId, targetFolderId);
            Site.Assert.IsNotNull(copiedItem, @"Copy recurring calendar item through RecurringMasterItemId should be successful.");
            ItemIdType calendarIdByCopied = copiedItem.Items.Items[0].ItemId;
            #endregion

            #region Call GetItem operation to verify whether the recurring calendar item is really copied
            getItem = this.GetSingleCalendarItem(Role.Organizer, calendarIdByCopied);

            if (Common.IsRequirementEnabled(806, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R806");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R806
                this.Site.CaptureRequirementIfIsNotNull(
                    getItem,
                    806,
                    @"[In Appendix C: Product Behavior] CopyItemSoapIn: For each item being copied that is a recurring calendar item, implementation does contain a RecurringMasterItemId child element ([MS-OXWSCORE] section 2.2.4.11). (Exchange 2007 and above follow this behavior.)");
            }
            #endregion

            #region Clean up organizer's drafts and calendar folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.drafts });
            #endregion
        }
        public void MSOXWSCORE_S07_TC16_GetTaskItemWithTwoItemIdTypesSuccessfully()
        {
            #region Step 1: Create a recurring task item.
            // Define the pattern and range of the recurring task item.
            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = 1;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            int numberOfOccurrences = 5;
            range.NumberOfOccurrences = numberOfOccurrences;
            System.DateTime start = System.DateTime.Now;
            range.StartDate = start;

            // Define the TaskType item.
            TaskType[] items = new TaskType[] { new TaskType() };
            items[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            items[0].Recurrence = new TaskRecurrenceType();
            items[0].Recurrence.Item = pattern;
            items[0].Recurrence.Item1 = range;

            // Call CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.tasks, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            BaseItemIdType[] createdTaskItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

            // One created task item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 createdTaskItemIds.GetLength(0),
                 "One created task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 createdTaskItemIds.GetLength(0));
            #endregion

            #region Step 2: Get the recurring task item by ItemIdType.
            // Call GetItem operation using the created task item ID.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(createdTaskItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
            #endregion

            // Exchange 2007 and Exchange 2010 do not support the RecurringMasterItemIdRanges element.
            SutVersion currentSutVersion = (SutVersion)Enum.Parse(typeof(SutVersion), Common.GetConfigurationPropertyValue("SutVersion", this.Site));
            if (currentSutVersion.Equals(SutVersion.ExchangeServer2013))
            {
                #region Step 3: Get the recurring task item by RecurringMasterItemIdRangesType.
                // Define the RecurringMasterItemIdRanges using the created task item ID.
                RecurringMasterItemIdRangesType[] recurringMasterItemIdRanges = new RecurringMasterItemIdRangesType[1];
                recurringMasterItemIdRanges[0] = new RecurringMasterItemIdRangesType();
                recurringMasterItemIdRanges[0].Id = (createdTaskItemIds[0] as ItemIdType).Id;
                recurringMasterItemIdRanges[0].ChangeKey = (createdTaskItemIds[0] as ItemIdType).ChangeKey;
                recurringMasterItemIdRanges[0].Ranges = new OccurrencesRangeType[1];
                recurringMasterItemIdRanges[0].Ranges[0] = new OccurrencesRangeType();
                recurringMasterItemIdRanges[0].Ranges[0].CompareOriginalStartTimeSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].CompareOriginalStartTime = true;
                recurringMasterItemIdRanges[0].Ranges[0].StartSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].Start = start;
                recurringMasterItemIdRanges[0].Ranges[0].EndSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].End = start.AddDays(numberOfOccurrences);

                // Call GetItem operation using the recurringMasterItemIdRanges.
                getItemResponse = this.CallGetItemOperation(recurringMasterItemIdRanges);

                // Check the operation response.
                Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
                #endregion
            }
        }
        public void MSOXWSMTGS_S02_TC03_UpdateRecurringCalendar()
        {
            #region Define a recurring calendar item
            DateTime startTime = DateTime.Now;

            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = this.PatternInterval;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = this.NumberOfOccurrences;
            range.StartDate = startTime;

            CalendarItemType meetingItem = new CalendarItemType();
            meetingItem.UID = Guid.NewGuid().ToString();
            meetingItem.Subject = this.Subject;
            meetingItem.Start = startTime;
            meetingItem.StartSpecified = true;
            meetingItem.End = startTime.AddHours(this.TimeInterval);
            meetingItem.EndSpecified = true;
            meetingItem.Location = this.Location;
            meetingItem.Recurrence = new RecurrenceType();
            meetingItem.Recurrence.Item = pattern;
            meetingItem.Recurrence.Item1 = range;
            meetingItem.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) };
            meetingItem.OptionalAttendees = new AttendeeType[] { GetAttendeeOrResource(this.OrganizerEmailAddress) };
            meetingItem.Resources = new AttendeeType[] { GetAttendeeOrResource(this.RoomEmailAddress) };
            #endregion

            #region Organizer creates a recurring calendar item with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R494");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R494
            Site.CaptureRequirementIfIsNotNull(
                 item,
                 494,
                 @"[In CreateItem Operation] This operation [CreateItem] can be used to create meetings.");
            #endregion

            #region Organizer updates the Location element of the first occurrence of the recurring calendar item
            CalendarItemType calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The meeting should be found in the organizer's Calendar folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll.");

            OccurrenceItemIdType occurrenceId = new OccurrenceItemIdType();
            occurrenceId.RecurringMasterId = calendar.ItemId.Id;
            occurrenceId.InstanceIndex = 1;

            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceId);
            Site.Assert.IsNotNull(getItem, "The updated occurrence should exist.");

            // Update the first occurrence of the recurring meeting
            CalendarItemType calendarUpdate = new CalendarItemType();
            calendarUpdate.Location = this.LocationUpdate;

            AdapterHelper itemChangeInfo = new AdapterHelper();
            itemChangeInfo.FieldURI = UnindexedFieldURIType.calendarLocation;
            itemChangeInfo.Item = calendarUpdate;
            itemChangeInfo.ItemId = getItem.Items.Items[0].ItemId;

            UpdateItemResponseMessageType updatedItem = this.UpdateSingleCalendarItem(Role.Organizer, itemChangeInfo, CalendarItemUpdateOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(updatedItem, "The UpdateItem operation should be successful.");
            #endregion

            #region Attendee verifies whether the location of the first occurrence of the recurring calendar item has been updated
            CalendarItemType updatedOccurrence = null;
            bool locationUpdateSuccess = false;
            int counter = 0;
            while (counter < this.UpperBound)
            {
                System.Threading.Thread.Sleep(this.WaitTime);
                calendar = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
                Site.Assert.IsNotNull(calendar, "The meeting should be found in attendee's Calendar folder after organizer updates the meeting.");

                occurrenceId = new OccurrenceItemIdType();
                occurrenceId.RecurringMasterId = calendar.ItemId.Id;
                occurrenceId.InstanceIndex = 1;

                getItem = this.GetSingleCalendarItem(Role.Attendee, occurrenceId);
                Site.Assert.IsNotNull(getItem, "The updated occurrence should exist.");

                updatedOccurrence = getItem.Items.Items[0] as CalendarItemType;

                locationUpdateSuccess = string.Compare(this.LocationUpdate, updatedOccurrence.Location, true) == 0;
                if (locationUpdateSuccess)
                {
                    break;
                }

                counter++;
            }

            if (counter == this.UpperBound && !locationUpdateSuccess)
            {
                Site.Assert.Fail("Attendee should get the update information of calendar by the organizer.");
            }

            MeetingRequestMessageType updateRequest = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType;
            Site.Assert.IsNotNull(updateRequest, "The meeting update request should be found in attendee's inbox folder after organizer updates the meeting.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R277");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R277
            this.Site.CaptureRequirementIfIsNotNull(
                updateRequest.RecurrenceId,
                277,
                "[In t:MeetingMessageType Complex Type] RecurrenceId: Identifies a specific instance of a recurring calendar item.");
            #endregion

            #region Attendee declines the meeting request with CalendarItemCreateOrDeleteOperationType value set to SendOnlyToAll
            DeclineItemType declineItem = new DeclineItemType();
            declineItem.ReferenceItemId = new ItemIdType();
            declineItem.ReferenceItemId = updatedOccurrence.ItemId;

            item = this.CreateSingleCalendarItem(Role.Attendee, declineItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll);
            Site.Assert.IsNotNull(item, "The response messages returned by the CreateItem operation should succeed.");
            #endregion

            #region Organizer calls FindItem to re-obtain the ItemId of the updated recurring calendar item because the changekey of ItemId is updated
            MeetingResponseMessageType response = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Resp", meetingItem.UID) as MeetingResponseMessageType;
            Site.Assert.IsNotNull(response, "The declined meeting response returned by Attendee should be in organizer's Inbox folder.");

            if (Common.IsRequirementEnabled(80049, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R80049");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R80049
                this.Site.CaptureRequirementIfIsTrue(
                    response.IsOrganizer,
                    80049,
                    "[In Appendix C: Product Behavior] Implementation does support the IsOrganizer, which specifies whether the current user is the organizer of the meeting. (Exchange 2013 and above follow this behavior.)");
            }

            if (Common.IsRequirementEnabled(909, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R909");

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R909
                Site.CaptureRequirementIfIsNotNull(
                     response.Recurrence,
                     909,
                     @"[In Appendix C: Product Behavior] Implementation does support Recurrence which is a RecurrenceType element that represents the recurrence for the calendar item. (Exchange 2013 and above follow this behavior.)");
            }
            #endregion

            #region Clean up organizer's inbox, calendar and deleteditems folders, and attendee's inbox, calendar and sentitems folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.deleteditems });
            this.CleanupFoldersByRole(Role.Attendee, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.calendar });
            #endregion
        }