private RecurrenceRange ConvertRecurrenceRange(ExTimeZone startTimeZone, ExTimeZone endTimeZone, RecurrenceRangeBaseType range)
        {
            ExDateTime startDate = new ExDateTime(startTimeZone, this.NormalizeDateToUtc(range.StartDate));
            NumberedRecurrenceRangeType numberedRecurrenceRangeType = range as NumberedRecurrenceRangeType;

            if (numberedRecurrenceRangeType != null)
            {
                return(new NumberedRecurrenceRange(startDate, numberedRecurrenceRangeType.NumberOfOccurrences));
            }
            EndDateRecurrenceRangeType endDateRecurrenceRangeType = range as EndDateRecurrenceRangeType;

            if (endDateRecurrenceRangeType != null)
            {
                ExDateTime exDateTime = new ExDateTime(startTimeZone, this.NormalizeDateToUtc(endDateRecurrenceRangeType.EndDate));
                if (exDateTime > Recurrence.MaximumDateForRecurrenceEnd)
                {
                    return(new NoEndRecurrenceRange(startDate));
                }
                return(new EndDateRecurrenceRange(startDate, exDateTime));
            }
            else
            {
                NoEndRecurrenceRangeType noEndRecurrenceRangeType = range as NoEndRecurrenceRangeType;
                if (noEndRecurrenceRangeType != null)
                {
                    return(new NoEndRecurrenceRange(startDate));
                }
                AppointmentTranslator.Tracer.TraceError <AppointmentTranslator, RecurrenceRangeBaseType>((long)this.GetHashCode(), "{0}: Unknown recurrence range: {1}", this, range);
                throw new InvalidAppointmentException();
            }
        }
        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 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_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
        }
        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
        }
示例#7
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_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
        }