Microsoft.Protocols.TestSuites.MS_OXWSMTGS.S01_CreateGetDeleteCalendarRelatedItem.VerifyModifiedOccurrences C# (CSharp) Method

VerifyModifiedOccurrences() private method

Verify ModifiedOccurrences property of a recurring meeting.
private VerifyModifiedOccurrences ( RecurrencePatternBaseType pattern, RecurrenceRangeBaseType range ) : void
pattern RecurrencePatternBaseType The recurring pattern.
range Microsoft.Protocols.TestSuites.Common.RecurrenceRangeBaseType The recurring range.
return void
        private void VerifyModifiedOccurrences(RecurrencePatternBaseType pattern, RecurrenceRangeBaseType range)
        {
            #region Step1: Organizer creates a recurring meeting
            // Define a recurring meeting.
            CalendarItemType meetingItem = this.DefineRecurringMeeting(pattern, range);
            Site.Assert.IsNotNull(meetingItem, "The meeting item should be created first.");

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

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

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

            item = this.GetSingleCalendarItem(Role.Organizer, item.Items.Items[0].ItemId);
            CalendarItemType calendar = item.Items.Items[0] as CalendarItemType;

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R742
            this.Site.CaptureRequirementIfAreEqual<int>(
                meetingItem.ConferenceType,
                calendar.ConferenceType,
                742,
                @"[In t:CalendarItemType Complex Type] [ConferenceType: Valid values include:] 1: presentation");
            #endregion

            #region Step2: Attendee gets and verifies the recurring meeting request
            int upperBound = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int count = 1;

            MeetingRequestMessageType request = null;

            while (request == null && count++ <= upperBound)
            {
               request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType;
               System.Threading.Thread.Sleep(waitTime);
            }
             
            Site.Assert.IsNotNull(request, "Attendee should receive the meeting request message in the Inbox folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendOnlyToAll.");

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

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R80048
                this.Site.CaptureRequirementIfIsFalse(
                    request.IsOrganizer,
                    80048,
                    @"[In Appendix C: Product Behavior] Implementation does support complex type ""IsOrganizer"" with type ""xs:boolean"" which specifies whether the current user is the organizer and/or owner of the calendar item. (Exchange 2013 and above follow this behavior.)");
            }

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

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

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R28503
            this.Site.CaptureRequirementIfAreEqual<LegacyFreeBusyType>(
                LegacyFreeBusyType.OOF,
                request.IntendedFreeBusyStatus,
                28503,
                @"[In t:MeetingRequestMessageType Complex Type] The IntendedFreeBusyStatus which value is ""OOF"" specifies the status as Out of Office (OOF).");

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

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R807
                this.Site.CaptureRequirementIfIsNotNull(
                    request,
                    807,
                    @"[In Appendix C: Product Behavior] GetItemSoapIn: For each item being retrieved that is a recurring calendar item, implementation does contain a RecurringMasterItemId child element ([MS-OXWSCORE] section 2.2.4.11) or an OccurrenceItemId child element ([MS-OXWSCORE] section 2.2.4.11). (Exchange 2007 and above follow this behavior.)");
            }

            // Verify the calendar item
            calendar = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The calendar item to be verified should exist in Attendee's Calendar folder.");

            ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Attendee, calendar.FirstOccurrence.ItemId);
            CalendarItemType firstOccurrence = getItem.Items.Items[0] as CalendarItemType;

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R54
            this.Site.CaptureRequirementIfAreEqual<CalendarItemTypeType>(
                CalendarItemTypeType.Occurrence,
                firstOccurrence.CalendarItemType1,
                54,
                @"[In t:CalendarItemTypeType Simple Type] Occurrence: Specifies that the item is an occurrence of a recurring calendar item.");

            #region Capture Code for CalendarItemType

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R744
            this.Site.CaptureRequirementIfIsTrue(
                calendar.AllowNewTimeProposalSpecified && calendar.AllowNewTimeProposal,
                744,
                @"[In t:CalendarItemType Complex Type] [AllowNewTimeProposal is] True, if a new meeting time can be proposed for a meeting by an attendee.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R56
            this.Site.CaptureRequirementIfAreEqual<CalendarItemTypeType>(
                CalendarItemTypeType.RecurringMaster,
                calendar.CalendarItemType1,
                56,
                @"[In t:CalendarItemTypeType Simple Type] RecurringMaster: Specifies that the item is the master item that contains the recurrence pattern for a calendar item.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R732
            bool isChecked = calendar.IsRecurringSpecified && calendar.IsRecurring;
            this.Site.CaptureRequirementIfIsTrue(
                isChecked,
                732,
                @"[In t:CalendarItemType Complex Type] [IsRecurring is] True, if a calendar item is part of a recurring item.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R737
            isChecked = calendar.IsResponseRequestedSpecified && calendar.IsResponseRequested;

            this.Site.CaptureRequirementIfIsFalse(
                isChecked,
                737,
                @"[In t:CalendarItemType Complex Type] otherwise [if a response to an item is not requested], [IsResponseRequested is] false.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R739
            this.Site.CaptureRequirementIfAreEqual<int>(
                3,
                calendar.AppointmentState,
                739,
                @"[In t:CalendarItemType Complex Type] [AppointmentState: Valid values include:] 3: the meeting request corresponding to the calendar item has been received");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R760
            isChecked = calendar.IsRecurringSpecified && calendar.IsRecurring;
            this.Site.CaptureRequirementIfIsTrue(
                isChecked,
                760,
                @"[In t:MeetingRequestMessageType Complex Type] [IsRecurring is] True, if the meeting is part of a recurring series of meetings.");

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

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R701
                this.Site.CaptureRequirementIfAreEqual<string>(
                    "Greenwich Standard Time",
                    calendar.StartTimeZoneId,
                    701,
                    @"[In Appendix C: Product Behavior] Implementation does support complex type ""StartTimeZoneId"" with type ""xs:string"" which specifies the calendar item start time zone identifier. (Exchange 2013 and above follow this behavior.)");
            }

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

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R702
                this.Site.CaptureRequirementIfAreEqual<string>(
                    "Greenwich Standard Time",
                    calendar.EndTimeZoneId,
                    702,
                    @"[In Appendix C: Product Behavior] Implementation does support complex type ""EndTimeZoneId"" with type ""xs:string"" which specifies the calendar item end time zone identifier. (Exchange 2013 and above follow this behavior.)");
            }

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

                // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R703
                this.Site.CaptureRequirementIfAreEqual<LegacyFreeBusyType>(
                    LegacyFreeBusyType.OOF,
                    calendar.IntendedFreeBusyStatus,
                    703,
                    @"[In Appendix C: Product Behavior] Implementation does support complex type ""IntendedFreeBusyStatus"" with type ""LegacyFreeBusyType ([MS-OXWSCDATA] section 2.2.3.16)"" which indicates how the organizer of the meeting wants it to show up in the attendee's calendar when the meeting is accepted. (Exchange 2013 and above follow this behavior.)");
            }

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R18407
            isChecked = !string.IsNullOrEmpty(calendar.Organizer.Item.EmailAddress);
            this.Site.CaptureRequirementIfIsTrue(
                isChecked,
                18407,
                @"[In t:CalendarItemType Complex Type] When the Mailbox element of Organizer element include an EmailAddress element of t:NonEmptyStringType, the t:NonEmptyStringType simple type specifies a string that MUST have a minimum of one character.");
            #endregion

            // Verify Recurrence
            Site.Assert.IsNotNull(calendar.Recurrence, "The Recurrence property of the calendar should not be null.");
            Site.Assert.IsNotNull(calendar.Recurrence.Item, "The pattern of the calendar should not be null.");
            Site.Assert.IsNotNull(calendar.Recurrence.Item1, "The range of the calendar should not be null.");
            this.VerifyReccurrenceType(calendar.Recurrence);
            #endregion

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

            // Update the occurrence.
            bool isUpdated = this.UpdateOccurrenceItem(occurrence);

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R651
            this.Site.CaptureRequirementIfIsTrue(
                isUpdated,
                651,
                @"[In Messages] UpdateItemSoapIn: For each item being updated that is a recurring calendar item, the ItemChange element can contain a RecurringMasterItemId child element ([MS-OXWSCORE] section 3.1.4.9.3.7) or an OccurrenceItemId child element ([MS-OXWSCORE] section 3.1.4.9.3.7).");

            CalendarItemType calendarItem = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendarItem, "The calendar item should exist.");
            Site.Assert.IsTrue(calendarItem.CalendarItemType1 == CalendarItemTypeType.RecurringMaster, "The type of the calendar should be RecurringMaster.");
            Site.Assert.IsNotNull(calendarItem.ModifiedOccurrences, "The ModifiedOccurrences should contain one occurrence at least.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R377
            this.Site.CaptureRequirementIfAreEqual<string>(
                calendarItem.FirstOccurrence.ItemId.Id,
                calendarItem.ModifiedOccurrences[0].ItemId.Id,
                377,
                @"[In t:NonEmptyArrayOfOccurrenceInfoType Complex Type] Occurrence: Represents a modified occurrence of a recurring calendar item.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R217
            this.Site.CaptureRequirementIfAreEqual<string>(
                calendarItem.FirstOccurrence.ItemId.Id,
                calendarItem.ModifiedOccurrences[0].ItemId.Id,
                217,
                @"[In t:CalendarItemType Complex Type]ModifiedOccurrences: Specifies recurring calendar item occurrences that have been modified so that they differ from original occurrences (or instances of the recurring master item).");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R381
            this.Site.CaptureRequirementIfAreEqual<string>(
                calendarItem.FirstOccurrence.ItemId.Id,
                calendarItem.ModifiedOccurrences[0].ItemId.Id,
                381,
                @"[In t:OccurrenceInfoType Complex Type] ItemId: Contains the identifier of a modified occurrence of a recurring calendar item.");

            CalendarItemType occurrenceCalendar = occurrence as CalendarItemType;
            Site.Assert.IsNotNull(occurrenceCalendar, "The type conversion from ItemType to CalendarItemType should succeed.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R383
            this.Site.CaptureRequirementIfAreEqual<DateTime>(
                occurrenceCalendar.Start.AddHours(-26.0),
                calendarItem.ModifiedOccurrences[0].Start,
                383,
                @"[In t:OccurrenceInfoType Complex Type] Start: Contains the start time of a modified occurrence of a recurring calendar item.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R385
            this.Site.CaptureRequirementIfAreEqual<DateTime>(
                occurrenceCalendar.End.AddHours(-26.0),
                calendarItem.ModifiedOccurrences[0].End,
                385,
                @"[In t:OccurrenceInfoType Complex Type] End: Contains the end time of a modified occurrence of a recurring calendar item.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R387
            this.Site.CaptureRequirementIfAreEqual<DateTime>(
                occurrenceCalendar.OriginalStart,
                calendarItem.ModifiedOccurrences[0].OriginalStart,
                387,
                @"[In t:OccurrenceInfoType Complex Type] OriginalStart: Contains the original start time of a modified occurrence of a recurring calendar item.");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R161
            this.Site.CaptureRequirementIfAreEqual<DateTime>(
                occurrenceCalendar.Start,
                calendarItem.FirstOccurrence.OriginalStart,
                161,
                @"[In t:CalendarItemType Complex Type] OriginalStart: Represents the original start time of a calendar item (only for occurrences/exceptions).");
            #endregion
            #endregion

            #region Step4: Attendee gets and verifies the modified occurrence
            CalendarItemType updatedOccurrence = null;
            int counter = 0;
            while (counter < this.UpperBound)
            {
                System.Threading.Thread.Sleep(this.WaitTime);
                updatedOccurrence = this.GetFirstOccurrenceItem(meetingItem, Role.Attendee) as CalendarItemType;

                if (updatedOccurrence.Location.ToLower() == this.LocationUpdate.ToLower())
                {
                    break;
                }

                counter++;
            }

            if (counter == this.UpperBound && updatedOccurrence.Location.ToLower() != this.LocationUpdate.ToLower())
            {
                Site.Assert.Fail("Attendee should get the updates after organizer updates the meeting.");
            }

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R55
            this.Site.CaptureRequirementIfAreEqual<CalendarItemTypeType>(
                CalendarItemTypeType.Exception,
                updatedOccurrence.CalendarItemType1,
                55,
                @"[In t:CalendarItemTypeType Simple Type] Exception: Specifies that the item is an exception to a recurring calendar item.");

            Site.Assert.AreEqual<string>(
                this.LocationUpdate,
                updatedOccurrence.Location,
                string.Format("The value of Location property of the updated occurrence is Expected: {0}; Actual: {1}", this.LocationUpdate, updatedOccurrence.Location));
            #endregion

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