/// <summary>
        /// Create an item in the specified folder.
        /// </summary>
        /// <param name="parentFolderType">Type of the parent folder.</param>
        /// <param name="parentFolderId">ID of the parent folder.</param>
        /// <param name="itemSubject">Subject of the item which should be created.</param>
        /// <returns>ID of the created item.</returns>
        protected ItemIdType CreateItem(DistinguishedFolderIdNameType parentFolderType, string parentFolderId, string itemSubject)
        {
            // Create a request for the CreateItem operation and initialize the ItemType instance.
            CreateItemType createItemRequest = new CreateItemType();
            ItemType       item = null;

            // Get different values for item based on different parent folder type.
            switch (parentFolderType)
            {
            case DistinguishedFolderIdNameType.contacts:
                ContactItemType contact = new ContactItemType();
                contact.Subject = itemSubject;
                contact.FileAs  = itemSubject;
                item            = contact;
                break;

            case DistinguishedFolderIdNameType.calendar:
                // Set the sendMeetingInvitations property.
                CalendarItemCreateOrDeleteOperationType sendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone;
                createItemRequest.SendMeetingInvitations          = (CalendarItemCreateOrDeleteOperationType)sendMeetingInvitations;
                createItemRequest.SendMeetingInvitationsSpecified = true;
                CalendarItemType calendar = new CalendarItemType();
                calendar.Subject = itemSubject;
                item             = calendar;
                break;

            case DistinguishedFolderIdNameType.inbox:
                MessageType message = new MessageType();
                message.Subject = itemSubject;
                item            = message;
                break;

            case DistinguishedFolderIdNameType.tasks:
                TaskType taskItem = new TaskType();
                taskItem.Subject = itemSubject;
                item             = taskItem;
                break;

            default:
                Site.Assert.Fail("The parent folder type '{0}' is invalid and the valid folder types are: contacts, calendar, inbox and tasks.", parentFolderType.ToString());
                break;
            }

            // Set the MessageDisposition property.
            MessageDispositionType messageDisposition = MessageDispositionType.SaveOnly;

            createItemRequest.MessageDisposition          = (MessageDispositionType)messageDisposition;
            createItemRequest.MessageDispositionSpecified = true;

            // Specify the folder in which new items are saved.
            createItemRequest.SavedItemFolderId = new TargetFolderIdType();
            FolderIdType folderId = new FolderIdType();

            folderId.Id = parentFolderId;
            createItemRequest.SavedItemFolderId.Item = folderId;

            // Specify the collection of items to be created.
            createItemRequest.Items       = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { item };

            // Initialize the ID of the created item.
            ItemIdType createdItemId = null;

            // Invoke the create item operation and get the response.
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);

            if (createItemResponse != null && createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
            {
                ItemInfoResponseMessageType info = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
                Site.Assert.IsNotNull(info, "The items in CreateItem response should not be null.");

                // Get the ID of the created item.
                createdItemId = info.Items.Items[0].ItemId;
            }

            return(createdItemId);
        }
        /// <summary>
        /// Verify the value of CalendarItemCreateOrDeleteOperationType.
        /// </summary>
        /// <param name="calendarItemCreateOrDeleteOperationType">Specify a value of CalendarItemCreateOrDeleteOperationType;</param>
        private void VerifyCalendarItemCreateOrDeleteOperationType(CalendarItemCreateOrDeleteOperationType calendarItemCreateOrDeleteOperationType)
        {
            #region Step1: Organizer set the properties of the meeting to create
            CalendarItemType meeting = new CalendarItemType();
            meeting.UID = Guid.NewGuid().ToString();
            meeting.Subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("MeetingSubject", this.Site));

            meeting.RequiredAttendees = new AttendeeType[] { GetAttendeeOrResource(this.AttendeeEmailAddress) };
            meeting.OptionalAttendees = new AttendeeType[] { GetAttendeeOrResource(this.OrganizerEmailAddress) };
            #endregion

            #region Step2: Organizer creates the meeting
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meeting, calendarItemCreateOrDeleteOperationType);
            Site.Assert.IsNotNull(item, "Create a meeting item should be successful.");
            ItemIdType meetingId = item.Items.Items[0].ItemId;
            #endregion

            #region Step3: Verify CalendarItemCreateOrDeleteOperationType used in CreateItem operation
            #region find the message in Organizer Calendar
            bool createdIsFoundInOrgnizerCalendar = false;
            if (null != this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meeting.UID))
            {
                createdIsFoundInOrgnizerCalendar = true;
            }
            #endregion

            #region find the message in Organizer SentItems
            bool createdIsFoundInOrgnizerSentItems = false;
            if (null != this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.sentitems, "IPM.Schedule.Meeting.Request", meeting.UID))
            {
                createdIsFoundInOrgnizerSentItems = true;
            }
            #endregion

            #region find the message in Attendee Inbox
            bool createdIsFoundInAttendeeInbox = false;
            if (null != this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Request", meeting.UID))
            {
                createdIsFoundInAttendeeInbox = true;
            }
            #endregion

            #region find the message in Attendee Calendar
            bool createdIsFoundInAttendeeCalendars = false;
            if (null != this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meeting.UID))
            {
                createdIsFoundInAttendeeCalendars = true;
            }
            #endregion

            #region Verify relevant requirements for CalendarItemCreateOrDeleteOperationType used in CreateItem operation
            switch (calendarItemCreateOrDeleteOperationType)
            {
                case CalendarItemCreateOrDeleteOperationType.SendOnlyToAll:
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R46");

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInOrgnizerCalendar,
                        46,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendOnlyToAll: For the CreateItem operation, this value specifies that the meeting is created in the organizer's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInAttendeeInbox,
                        4600,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendOnlyToAll: [For the CreateItem operation, this value specifies that] a meeting request is sent to all attendees.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInAttendeeCalendars,
                        4601,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendOnlyToAll: [For the CreateItem operation, this value specifies that] the meeting is created in each attendee's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsFalse(
                        createdIsFoundInOrgnizerSentItems,
                        4602,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendOnlyToAll: [For the CreateItem operation, this value specifies that] No copy of the meeting request is saved in the organizer's Sent Items folder.");
                    break;

                case CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy:
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R48");

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInOrgnizerCalendar,
                        48,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToAllAndSaveCopy: For the CreateItem operation, this value specifies that the meeting is created in the organizer's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInAttendeeInbox,
                        4800,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToAllAndSaveCopy: [For the CreateItem operation, this value specifies that] a meeting request is sent to all attendees.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInAttendeeCalendars,
                        4801,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToAllAndSaveCopy: [For the CreateItem operation, this value specifies that] the meeting is created in each attendee's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInOrgnizerSentItems,
                        4802,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToAllAndSaveCopy: [For the CreateItem operation, this value specifies that] A copy of the meeting request is saved in the organizer's Sent Items folder.");
                    break;

                case CalendarItemCreateOrDeleteOperationType.SendToNone:
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R44");

                    this.Site.CaptureRequirementIfIsTrue(
                        createdIsFoundInOrgnizerCalendar,
                        44,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToNone: For the CreateItem operation ([MS-OXWSCORE] section 3.1.4.2), this value specifies that the meeting is created in the organizer's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsFalse(
                        createdIsFoundInAttendeeInbox,
                        4400,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToNone: [For the CreateItem operation ([MS-OXWSCORE] section 3.1.4.2), this value specifies that] no meeting request is sent to attendees.");

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

                    this.Site.CaptureRequirementIfIsFalse(
                        createdIsFoundInAttendeeCalendars,
                        4401,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToNone: [For the CreateItem operation ([MS-OXWSCORE] section 3.1.4.2), this value specifies that the meeting is created in the organizer's Calendar folder but no meeting request is sent to attendees.] Because no meeting request is generated, the meeting is not created in each attendee's Calendar folder.");
                    break;
            }
            #endregion
            #endregion

            #region Step4: Organizer delete the calendar item
            ResponseMessageType deletedItem = this.DeleteSingleCalendarItem(Role.Organizer, meetingId, calendarItemCreateOrDeleteOperationType);
            Site.Assert.IsNotNull(deletedItem, "Organizer should delete the calendar item successfully.");
            #endregion

            #region Step5: verify CalendarItemCreateOrDeleteOperationType used in DeleteItem operation
            #region find the message in Organizer Calendar
            bool deletedIsFoundInOrgnizerCalendar = false;

            if (null != this.SearchDeletedSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meeting.UID))
            {
                deletedIsFoundInOrgnizerCalendar = true;
            }
            #endregion

            #region find the message in Organizer SentItems
            bool deletedIsFoundInOrgnizerSentItems = false;
            if (null != this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.sentitems, "IPM.Schedule.Meeting.Canceled", meeting.UID))
            {
                deletedIsFoundInOrgnizerSentItems = true;
            }
            #endregion

            #region find the message in Attendee Inbox
            bool deletedIsFoundInAttendeeInbox = false;
            if (null != this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Canceled", meeting.UID))
            {
                deletedIsFoundInAttendeeInbox = true;
            }
            #endregion

            #region Verify relevant requirements for CalendarItemCreateOrDeleteOperationType used in DeleteItem operation
            switch (calendarItemCreateOrDeleteOperationType)
            {
                case CalendarItemCreateOrDeleteOperationType.SendOnlyToAll:
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R47");

                    this.Site.CaptureRequirementIfIsFalse(
                        deletedIsFoundInOrgnizerCalendar,
                        47,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendOnlyToAll: For the DeleteItem operation, this value specifies that the meeting is deleted from the organizer's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        deletedIsFoundInAttendeeInbox,
                        4700,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendOnlyToAll: [For the DeleteItem operation, this value specifies that the meeting is deleted from the organizer's Calendar folder and] a meeting cancellation message is sent to all attendees.");

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

                    this.Site.CaptureRequirementIfIsFalse(
                        deletedIsFoundInOrgnizerSentItems,
                        4701,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendOnlyToAll: [For the DeleteItem operation, this value specifies that] no copy of the meeting cancellation message is saved.");
                    break;

                case CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy:
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R49");

                    this.Site.CaptureRequirementIfIsFalse(
                        deletedIsFoundInOrgnizerCalendar,
                        49,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToAllAndSaveCopy: For the DeleteItem operation, this value specifies that the meeting is deleted from the organizer's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        deletedIsFoundInAttendeeInbox,
                        4900,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToAllAndSaveCopy: [For the DeleteItem operation, this value specifies that] a meeting cancellation message is sent to all attendees.");

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

                    this.Site.CaptureRequirementIfIsTrue(
                        deletedIsFoundInOrgnizerSentItems,
                        4901,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToAllAndSaveCopy: [For the DeleteItem operation, this value specifies that] a copy of the meeting cancellation message is saved in the organizer's Sent Items folder.");
                    break;

                case CalendarItemCreateOrDeleteOperationType.SendToNone:
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R45");

                    this.Site.CaptureRequirementIfIsFalse(
                        deletedIsFoundInOrgnizerCalendar,
                        45,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToNone: For the DeleteItem operation ([MS-OXWSCORE] section 3.1.4.3) this value specifies that the meeting is deleted from the organizer's Calendar folder.");

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

                    this.Site.CaptureRequirementIfIsFalse(
                        deletedIsFoundInAttendeeInbox,
                        4500,
                        @"[In t:CalendarItemCreateOrDeleteOperationType Simple Type] SendToNone: [For the DeleteItem operation ([MS-OXWSCORE] section 3.1.4.3) this value specifies that] no meeting cancellation message is sent to attendees.");
                    break;
            }
            #endregion
            #endregion
        }