Microsoft.Protocols.TestSuites.MS_OXWSMTGS.S05_OperateMultipleCalendarRelatedItems.MSOXWSMTGS_S05_TC02_UpdateMultipleCalendarItems C# (CSharp) Method

MSOXWSMTGS_S05_TC02_UpdateMultipleCalendarItems() private method

private MSOXWSMTGS_S05_TC02_UpdateMultipleCalendarItems ( ) : void
return void
        public void MSOXWSMTGS_S05_TC02_UpdateMultipleCalendarItems()
        {
            #region Define two calendar items
            CalendarItemType calendarItem1 = new CalendarItemType();
            calendarItem1.UID = Guid.NewGuid().ToString();
            calendarItem1.Subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("MeetingSubject", this.Site));
            calendarItem1.Location = this.Location;

            CalendarItemType calendarItem2 = new CalendarItemType();
            calendarItem2.UID = Guid.NewGuid().ToString();
            calendarItem2.Subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("MeetingSubject", this.Site));
            calendarItem2.Location = this.Location;
            #endregion

            #region Create the two calendar items
            ItemInfoResponseMessageType[] calendars = this.CreateMultipleCalendarItems(Role.Organizer, new ItemType[] { calendarItem1, calendarItem2 }, CalendarItemCreateOrDeleteOperationType.SendToNone);
            Site.Assert.IsNotNull(calendars, "The calendars should be created successfully.");
            Site.Assert.IsTrue(calendars.Length == 2, "There should be only two calendars created.");

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

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1198
            // The calendars are gotten successfully, it means the calendars are created successfully.
            Site.CaptureRequirement(
                1198,
                @"[In Messages] A successful CreateItem operation returns a CreateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.2.2.2, with the ResponseClass attribute of the CreateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"".");

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

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1199
            // The calendars are gotten successfully, it means the calendars are created successfully.
            Site.CaptureRequirement(
                1199,
                @"[In Messages] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.43, of the CreateItemResponseMessage element is set to ""NoError"".");

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

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1217
            // The calendars are gotten successfully, this requirement can be captured.
            Site.CaptureRequirement(
                1217,
                @"[In Messages] A successful GetItem operation returns a GetItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.4.2.2, with the ResponseClass attribute of the GetItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". ");

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

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1218
            // The calendars are gotten successfully, this requirement can be captured.
            Site.CaptureRequirement(
                1218,
                @"[In Messages] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.43, of the GetItemResponseMessage element is set to ""NoError"".");

            ItemIdType[] calendarIds = new ItemIdType[] { calendars[0].Items.Items[0].ItemId, calendars[1].Items.Items[0].ItemId };
            #endregion

            #region Update the Location element of the two created calendar items
            List<AdapterHelper> itemsChangeInfo = new List<AdapterHelper>();
            foreach (ItemIdType calendarId in calendarIds)
            {
                CalendarItemType calendarUpdate = new CalendarItemType();
                calendarUpdate.Location = this.LocationUpdate;

                AdapterHelper itemChangeInfo = new AdapterHelper();
                itemChangeInfo.FieldURI = UnindexedFieldURIType.calendarLocation;
                itemChangeInfo.Item = calendarUpdate;
                itemChangeInfo.ItemId = calendarId;
                itemsChangeInfo.Add(itemChangeInfo);
            }

            Site.Assert.IsNotNull(
                this.UpdateMultipleCalendarItems(Role.Organizer, itemsChangeInfo.ToArray(), CalendarItemUpdateOperationType.SendToNone),
                "Server should return success for updating multiple calendar items.");

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

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1235
            // The updated calendars are gotten successfully, this requirement can be captured.
            Site.CaptureRequirement(
                1235,
                @"[In Messages] A successful UpdateItem operation returns an UpdateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.9.2.2, with the ResponseClass attribute of the UpdateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"".");

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

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1236
            // The updated calendars are gotten successfully, this requirement can be captured.
            Site.CaptureRequirement(
                1236,
                @"[In Messages] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.43, of the UpdateItemResponseMessage element is set to ""NoError"".");
            #endregion

            #region Verify the Location elements of the two calendar items are updated
            ItemInfoResponseMessageType getItem1 = this.GetSingleCalendarItem(Role.Organizer, calendarIds[0]);
            Site.Assert.IsNotNull(getItem1, "The first updated item should exist.");

            CalendarItemType calendar1 = getItem1.Items.Items[0] as CalendarItemType;
            Site.Assert.AreEqual<string>(
                this.LocationUpdate,
                calendar1.Location,
                string.Format("The Location of the first updated calendar should be {0}. The actual value is {1}.", this.LocationUpdate, calendar1.Location));

            ItemInfoResponseMessageType getItem2 = this.GetSingleCalendarItem(Role.Organizer, calendarIds[1]);
            Site.Assert.IsNotNull(getItem2, "The second updated item should exist.");

            CalendarItemType calendar2 = getItem2.Items.Items[0] as CalendarItemType;
            Site.Assert.AreEqual<string>(
                this.LocationUpdate,
                calendar2.Location,
                string.Format("The Location of the second updated calendar should be {0}. The actual value is {1}.", this.LocationUpdate, calendar2.Location));
            #endregion

            #region Clean up organizer's calendar folder.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.calendar });
            #endregion
        }