Inheritance: BaseRequestType
        /// <summary>
        /// Update the calendar related item elements.
        /// </summary>
        /// <param name="request">A request to the UpdateItem operation.</param>
        /// <returns>The response message returned by UpdateItem operation.</returns>
        public UpdateItemResponseType UpdateItem(UpdateItemType request)
        {
            if (request == null)
            {
                throw new ArgumentException("The request of operation 'UpdateItem' should not be null.");
            }

            UpdateItemResponseType updateItemResponse = this.exchangeServiceBinding.UpdateItem(request);
            Site.Assert.IsNotNull(updateItemResponse, "If the operation is successful, the response should not be null.");

            this.VerifySoapVersion();
            this.VerifyTransportType();
            this.VerifyUpdateItemOperation(updateItemResponse, this.exchangeServiceBinding.IsSchemaValidated);
            return updateItemResponse;
        }
        public void MSOXWSCORE_S08_TC05_UpdateTypesOfItemsFailed()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(19241, this.Site), "Exchange 2007 doesn't support MS-OXWSDLIST");

            #region Step 1: Create Items.
            ItemIdType[] createdItemIds = CreateAllTypesItems();
            #endregion

            #region Step 2: Update items.
            // Initialize the change item to update.
            UpdateItemType updateRequest = new UpdateItemType();
            ItemChangeType[] itemChanges = new ItemChangeType[createdItemIds.Length];

            // Set two properties (Subject and ReminderMinutesBeforeStart) to update, in order to return an error "ErrorIncorrectUpdatePropertyCount".
            for (int i = 0; i < createdItemIds.Length; i++)
            {
                itemChanges[i] = new ItemChangeType();
                itemChanges[i].Item = createdItemIds[i];
                itemChanges[i].Updates = new ItemChangeDescriptionType[1];
                SetItemFieldType setItem1 = new SetItemFieldType();
                setItem1.Item = new PathToUnindexedFieldType()
                {
                    FieldURI = UnindexedFieldURIType.itemSubject
                };
                setItem1.Item1 = new ContactItemType()
                {
                    Subject = Common.GenerateResourceName(
                        this.Site,
                        TestSuiteHelper.SubjectForUpdateItem),
                    ReminderMinutesBeforeStart = TestSuiteHelper.ReminderMinutesBeforeStart
                };
                itemChanges[i].Updates[0] = setItem1;
            }

            updateRequest.ItemChanges = itemChanges;
            updateRequest.MessageDispositionSpecified = true;
            updateRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            updateRequest.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToAllAndSaveCopy;
            updateRequest.SendMeetingInvitationsOrCancellationsSpecified = true;

            // Call UpdateItem to update the Subject and the ReminderMinutesBeforeStart of the created item simultaneously.
            UpdateItemResponseType updateItemResponse = this.COREAdapter.UpdateItem(updateRequest);

            foreach (ResponseMessageType responseMessage in updateItemResponse.ResponseMessages.Items)
            {
                // Verify ResponseCode is ErrorIncorrectUpdatePropertyCount.
                this.VerifyErrorIncorrectUpdatePropertyCount(responseMessage.ResponseCode);
            }
            #endregion
        }
        public void MSOXWSCORE_S04_TC25_UpdateItemWithSuppressReadReceipts()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2315, this.Site), "Exchange 2007, Exchange 2010, and the initial release of Exchange 2013 do not support the SuppressReadReceipts attribute.");

            #region Send an email with setting IsReadReceiptRequested to true.

            MessageType message = new MessageType();
            message.IsReadReceiptRequestedSpecified = true;
            message.IsReadReceiptRequested = true;
            message.ToRecipients = new EmailAddressType[1];
            EmailAddressType recipient = new EmailAddressType();
            recipient.EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            message.ToRecipients[0] = recipient;
            message.From = new SingleRecipientType
            {
                Item = new EmailAddressType
                {
                    EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site)
                }
            };
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { message };
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 1);
            createItemRequest.MessageDisposition = MessageDispositionType.SendOnly;
            createItemRequest.MessageDispositionSpecified = true;
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            #endregion

            #region Find the email in receiver's inbox.

            ItemIdType[] findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2");
            Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email.");

            #endregion

            #region Update the found email with setting SuppressReadReceipts to true.

            ItemChangeType[] itemChanges = new ItemChangeType[1];
            itemChanges[0] = new ItemChangeType();
            itemChanges[0].Item = findItemIds[0];
            itemChanges[0].Updates = new ItemChangeDescriptionType[1];
            SetItemFieldType setItemFiled = new SetItemFieldType();
            setItemFiled.Item = new PathToUnindexedFieldType()
            {
                FieldURI = UnindexedFieldURIType.messageIsRead
            };
            setItemFiled.Item1 = new MessageType()
            {
                IsRead = true,
                IsReadSpecified = true
            };
            itemChanges[0].Updates[0] = setItemFiled;
            UpdateItemType updateItemType = new UpdateItemType();
            updateItemType.ItemChanges = itemChanges;
            updateItemType.ConflictResolution = ConflictResolutionType.AutoResolve;
            updateItemType.MessageDisposition = MessageDispositionType.SaveOnly;
            updateItemType.MessageDispositionSpecified = true;
            updateItemType.SuppressReadReceipts = true;
            updateItemType.SuppressReadReceiptsSpecified = true;
            UpdateItemResponseType updateItemResponse = this.COREAdapter.UpdateItem(updateItemType);
            Common.CheckOperationSuccess(updateItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.IsNull(findItemIds, "The read receipt email should not be received if receiver update the email with setting SuppressReadReceipts to true.");

            List<string> subjects = new List<string>();
            subjects.Add(createItemRequest.Items.Items[0].Subject);
            this.ExistItemIds.Clear();
            #endregion

            #region Send an email with setting IsReadReceiptRequested to true.

            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 2);
            createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            #endregion

            #region Find the email in receiver's inbox.

            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2");
            Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email.");

            #endregion

            #region Update the found email with setting SuppressReadReceipts to false.

            updateItemType.ItemChanges[0].Item = findItemIds[0];
            updateItemType.SuppressReadReceipts = false;
            updateItemResponse = this.COREAdapter.UpdateItem(updateItemType);
            Common.CheckOperationSuccess(updateItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.AreEqual<int>(1, findItemIds.Length, "The read receipt email should not be received if receiver update the email with setting SuppressReadReceipts to true.");
            subjects.Add(createItemRequest.Items.Items[0].Subject);
            this.ExistItemIds.Clear();
            this.ExistItemIds.Add(findItemIds[0]);
            this.CleanItemsSentOut(subjects.ToArray());

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2315
            // This requirement can be captured directly after above steps.
            this.Site.CaptureRequirement(
                2315,
                @"[In Appendix C: Product Behavior] Implementation does  support the SuppressReadReceipts attribute specifies whether read receipts are suppressed. (<102> Section 3.1.4.9.3.2:  This attribute [SuppressReadReceipts] was introduced in Exchange 2013 SP1.)");
            #endregion
        }
        /// <summary>
        /// Update items on the server.
        /// </summary>
        /// <param name="updateItemRequest">Specify a request to update items on the server.</param>
        /// <returns>A response to UpdateItem operation request.</returns>
        public UpdateItemResponseType UpdateItem(UpdateItemType updateItemRequest)
        {
            UpdateItemResponseType response = this.exchangeServiceBinding.UpdateItem(updateItemRequest);
            Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null.");

            // SOAP version is set to 1.1, if a response can be received from server, then it means SOAP 1.1 is supported.
            this.VerifySoapVersion();

            // Verify transport type related requirement.
            this.VerifyTransportType();

            this.VerifyServerVersionInfo(this.exchangeServiceBinding.ServerVersionInfoValue, this.exchangeServiceBinding.IsSchemaValidated);
            this.VerifyUpdateItemResponse(response, this.exchangeServiceBinding.IsSchemaValidated);
            return response;
        }
Exemplo n.º 5
0
 /// <remarks/>
 public void UpdateItemAsync(UpdateItemType UpdateItem1)
 {
     this.UpdateItemAsync(UpdateItem1, null);
 }
        public void MSOXWSMTGS_S02_TC12_UpdateItemErrorCalendarDurationIsTooLong()
        {
            #region Define a calendar item
            int timeInterval = this.TimeInterval;
            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            calendarItem.Start = DateTime.Now.AddHours(timeInterval);
            calendarItem.StartSpecified = true;
            calendarItem.End = calendarItem.Start.AddDays(6);
            calendarItem.EndSpecified = true;
            #endregion

            #region Create the recurring calendar item and extract the Id of an occurrence item
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { calendarItem };
            createItemRequest.MessageDispositionSpecified = true;
            createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            createItemRequest.SendMeetingInvitationsSpecified = true;
            createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone;
            CreateItemResponseType response = this.MTGSAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(response, 1, this.Site);
            #endregion

            #region Update the calendar to make the duration exceeds 5 years.
            CalendarItemType calendarUpdate = new CalendarItemType();
            calendarUpdate.End = calendarItem.Start.AddYears(6);
            calendarUpdate.EndSpecified = true;

            UpdateItemType updateItemRequest = new UpdateItemType();
            updateItemRequest.ItemChanges = new ItemChangeType[1];
            PathToUnindexedFieldType pathToUnindexedField = new PathToUnindexedFieldType();
            pathToUnindexedField.FieldURI = UnindexedFieldURIType.calendarEnd;
            SetItemFieldType setItemField = new SetItemFieldType();
            setItemField.Item = pathToUnindexedField;
            setItemField.Item1 = calendarUpdate;
            ItemChangeType itemChange = new ItemChangeType();
            itemChange.Item = (response.ResponseMessages.Items[0] as ItemInfoResponseMessageType).Items.Items[0].ItemId;
            itemChange.Updates = new ItemChangeDescriptionType[] { setItemField };
            updateItemRequest.ItemChanges[0] = itemChange;
            updateItemRequest.SendMeetingInvitationsOrCancellationsSpecified = true;
            updateItemRequest.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToNone;
            UpdateItemResponseType updateItemResponse = this.MTGSAdapter.UpdateItem(updateItemRequest);

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

            // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1244
            Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorCalendarDurationIsTooLong,
                updateItemResponse.ResponseMessages.Items[0].ResponseCode,
                1244,
                @"[In Messages] ErrorCalendarDurationIsTooLong: Specifies that the item duration of a calendar item exceeds five years.");
            #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
        }
        /// <summary>
        /// Update contact item on the server.
        /// </summary>
        /// <param name="updateItemRequest">The request of UpdateItem operation.</param>
        /// <returns>A response to UpdateItem operation request.</returns>
        public UpdateItemResponseType UpdateItem(UpdateItemType updateItemRequest)
        {
            UpdateItemResponseType updateItemResponse = this.exchangeServiceBinding.UpdateItem(updateItemRequest);

            #region Verify UpdateItem operation requirements

            this.VerifySoapVersion();
            this.VerifyTransportType();
            this.VerifyUpdateContactItem(this.exchangeServiceBinding.IsSchemaValidated);
            #endregion

            return updateItemResponse;
        }
        public void MSOXWSMSG_S07_TC05_VerifyInternetMessageIdIsReadOnly()
        {
            #region Create message
            CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts);
            CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest);
            Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);

            // Save the ItemId of message responseMessageItem returned from the createItem response.
            ItemIdType itemIdType = new ItemIdType();
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;
            #endregion

            #region update InternetMessageId property of the original message
            UpdateItemType updateItemRequest = new UpdateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,
                MessageDispositionSpecified = true,

                ItemChanges = new ItemChangeType[]
                {
                    new ItemChangeType
                    {
                        Item = itemIdType,                        

                        Updates = new ItemChangeDescriptionType[]
                        {
                            new SetItemFieldType
                            {
                                Item = new PathToUnindexedFieldType
                                {
                                    FieldURI = UnindexedFieldURIType.messageInternetMessageId
                                },
                                Item1 = new MessageType
                                {
                                     InternetMessageId = "InternetMessageId"     
                                }
                            }
                        }                   
                    }
                }
            };

            UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(ResponseCodeType.ErrorInvalidPropertySet, updateItemResponse.ResponseMessages.Items[0].ResponseCode, "Since InternetMessageId is read-only, then the The ErrorInvalidPropertySet should be returned by server.");

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

            // If the above steps are pass, the R58 will be verified.
            this.Site.CaptureRequirement(
                58,
                @"[In t:MessageType Complex Type] [InternetMessageId element] This element is read-only.");
            #endregion

            #region Clean up Sender's drafts folder
            bool isClear = this.MSGSUTControlAdapter.CleanupFolders(
                Common.GetConfigurationPropertyValue("Sender", this.Site),
                Common.GetConfigurationPropertyValue("SenderPassword", this.Site),
                this.Domain,
                this.Subject,
                "drafts");
            Site.Assert.IsTrue(isClear, "Sender's drafts folder should be cleaned up.");
            #endregion
        }
        public void MSOXWSMSG_S07_TC07_VerifyReceivedRepresentingIsReadOnly()
        {
            #region Create a message which include the ReceivedRepresenting element.
            CreateItemType createItemRequest = new CreateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,

                // MessageDispositionSpecified value needs to be set.
                MessageDispositionSpecified = true,

                SavedItemFolderId = new TargetFolderIdType
                {
                    Item = new DistinguishedFolderIdType
                    {
                        Id = DistinguishedFolderIdNameType.drafts
                    }
                },

                Items = new NonEmptyArrayOfAllItemsType
                {
                    Items = new MessageType[]
                    {
                        // Create a MessageType instance with all element.
                        new MessageType
                        {
                            // Specify the sender of the message.
                            Sender = new SingleRecipientType
                            {
                                Item = new EmailAddressType
                                {
                                    EmailAddress = this.Sender
                                }                                
                            },

                            // Specify the recipient of the message.
                            ToRecipients = new EmailAddressType[]
                            {
                                new EmailAddressType
                                {
                                     EmailAddress = this.Recipient1                               
                                }
                            },
                           ReceivedRepresenting = new SingleRecipientType()
                           {
                                Item = new EmailAddressType
                                {
                                    EmailAddress = this.Recipient1
                                }
                           }
                        }
                    }
                },
            };

            CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest);

            Site.Assert.AreEqual<ResponseCodeType>(ResponseCodeType.ErrorInvalidPropertySet, createItemResponse.ResponseMessages.Items[0].ResponseCode, "Since ReceivedRepresenting is read-only, then the The ErrorInvalidPropertySet should be returned by server.");
            #endregion

            #region Create message
            createItemRequest = this.GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts);
            createItemResponse = this.MSGAdapter.CreateItem(createItemRequest);
            Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);

            // Save the ItemId of message responseMessageItem returned from the createItem response.
            ItemIdType itemIdType = new ItemIdType();
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;
            #endregion

            #region update ReceivedRepresenting property of the original message
            UpdateItemType updateItemRequest = new UpdateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,
                MessageDispositionSpecified = true,

                ItemChanges = new ItemChangeType[]
                {
                    new ItemChangeType
                    {
                        Item = itemIdType,                        

                        Updates = new ItemChangeDescriptionType[]
                        {
                            new SetItemFieldType
                            {
                                Item = new PathToUnindexedFieldType
                                {
                                    FieldURI = UnindexedFieldURIType.messageReceivedRepresenting
                                },
                                Item1 = new MessageType
                                {
                                     ReceivedRepresenting = new SingleRecipientType()
                                     {
                                         Item = new EmailAddressType()
                                         {
                                             EmailAddress = this.Recipient1
                                         }
                                     }
                                }
                            }
                        }                   
                    }
                }
            };

            UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(ResponseCodeType.ErrorInvalidPropertySet, updateItemResponse.ResponseMessages.Items[0].ResponseCode, "Since ReceivedRepresenting is read-only, then the The ErrorInvalidPropertySet should be returned by server.");
            #endregion

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

            // If the above steps are pass, the R73001 will be verified.
            this.Site.CaptureRequirement(
                73001,
                @"[In t:MessageType Complex Type] [ReceivedRepresenting element] This element is read-only.");

            #region Clean up Sender's drafts folder
            bool isClear = this.MSGSUTControlAdapter.CleanupFolders(
                Common.GetConfigurationPropertyValue("Sender", this.Site),
                Common.GetConfigurationPropertyValue("SenderPassword", this.Site),
                this.Domain,
                this.Subject,
                "drafts");
            Site.Assert.IsTrue(isClear, "Sender's drafts folder should be cleaned up.");
            #endregion
        }
        public void MSOXWSMSG_S07_TC03_VerifyConversationIndexIsReadOnly()
        {
            #region Create a message which include the ConversationIndex element.
            CreateItemType createItemRequest = new CreateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,

                // MessageDispositionSpecified value needs to be set.
                MessageDispositionSpecified = true,

                SavedItemFolderId = new TargetFolderIdType
                {
                    Item = new DistinguishedFolderIdType
                    {
                        Id = DistinguishedFolderIdNameType.drafts
                    }
                },
                Items = new NonEmptyArrayOfAllItemsType
                {
                    Items = new MessageType[]
                    {
                        // Create a MessageType instance with all element.
                        new MessageType
                        {
                            // Specify the sender of the message.
                            Sender = new SingleRecipientType
                            {
                                Item = new EmailAddressType
                                {
                                    EmailAddress = this.Sender
                                }                                
                            },

                            // Specify the recipient of the message.
                            ToRecipients = new EmailAddressType[]
                            {
                                new EmailAddressType
                                {
                                     EmailAddress = this.Recipient1                               
                                }
                            },
                            ConversationIndex = new byte[] { },                                                                 
                        }
                    }
                },
            };

            CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest);

            Site.Assert.AreEqual<ResponseCodeType>(ResponseCodeType.ErrorInvalidPropertySet, createItemResponse.ResponseMessages.Items[0].ResponseCode, "Since ConversationIndex is read-only, then the The ErrorInvalidPropertySet should be returned by server.");
           
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                createItemResponse.ResponseMessages.Items[0].ResponseClass,
                113001,
                @"[In CreateItem] If the CreateItem WSDL operation is not successful, it returns a CreateItemResponse element with the ResponseClass attribute of the CreateItemResponseMessage element set to ""Error"". ");

            this.Site.CaptureRequirementIfIsTrue(
                System.Enum.IsDefined(typeof(ResponseCodeType), createItemResponse.ResponseMessages.Items[0].ResponseCode),
                113002,
                @"[In CreateItem] [A unsuccessful CreateItem operation request returns a CreateItemResponse element] The ResponseCode element of the CreateItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24.");
            #endregion

            #region Create message
            createItemRequest = this.GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts);
            createItemResponse = this.MSGAdapter.CreateItem(createItemRequest);
            Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);

            // Save the ItemId of message responseMessageItem returned from the createItem response.
            ItemIdType itemIdType = new ItemIdType();
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;
            #endregion

            #region update ConversationIndex property of the original message
            UpdateItemType updateItemRequest = new UpdateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,
                MessageDispositionSpecified = true,

                ItemChanges = new ItemChangeType[]
                {
                    new ItemChangeType
                    {
                        Item = itemIdType,                        

                        Updates = new ItemChangeDescriptionType[]
                        {
                            new SetItemFieldType
                            {
                                Item = new PathToUnindexedFieldType
                                {
                                    FieldURI = UnindexedFieldURIType.messageConversationIndex
                                },
                                Item1 = new MessageType
                                {
                                    ConversationIndex = new byte[] { }
                                }
                            }
                        }                   
                    }
                }
            };
  
            UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(ResponseCodeType.ErrorInvalidPropertySet, updateItemResponse.ResponseMessages.Items[0].ResponseCode, "Since ConversationIndex is read-only, then the The ErrorInvalidPropertySet should be returned by server.");

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

            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                updateItemResponse.ResponseMessages.Items[0].ResponseClass,
                145001,
                @"[In UpdateItem] If the UpdateItem WSDL operation request is not successful, it returns an UpdateItemResponse element with the ResponseClass attribute of the UpdateItemResponseMessage element set to ""Error"". ");

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

            this.Site.CaptureRequirementIfIsTrue(
                System.Enum.IsDefined(typeof(ResponseCodeType), updateItemResponse.ResponseMessages.Items[0].ResponseCode),
                145002,
                @"[In UpdateItem] [A unsuccessful UpdateItem operation request returns an UpdateItemResponse element] The ResponseCode element of the UpdateItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24.");

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

            // If the above steps are pass, the R49 will be verified.
            this.Site.CaptureRequirement(
                49,
                @"[In t:MessageType Complex Type] [ConversationIndex element] This element is read-only.");
            #endregion

            #region Clean up Sender's drafts folder
            bool isClear = this.MSGSUTControlAdapter.CleanupFolders(
                Common.GetConfigurationPropertyValue("Sender", this.Site),
                Common.GetConfigurationPropertyValue("SenderPassword", this.Site),
                this.Domain,
                this.Subject,
                "drafts");
            Site.Assert.IsTrue(isClear, "Sender's drafts folder should be cleaned up.");
            #endregion
        }
 /// <summary>
 /// Update item on the server.
 /// </summary>
 /// <param name="updateItemRequest">Update item operation request type.</param>
 /// <returns>Update item operation response type.</returns>
 public UpdateItemResponseType UpdateItem(UpdateItemType updateItemRequest)
 {
     UpdateItemResponseType updateItemResponse = this.exchangeServiceBinding.UpdateItem(updateItemRequest);
     return updateItemResponse;
 }
        /// <summary>
        /// Update items on the server.
        /// </summary>
        /// <param name="updateItemRequest">Specify a request to update items on the server.</param>
        /// <returns>A response to this operation request.</returns>
        public UpdateItemResponseType UpdateItem(UpdateItemType updateItemRequest)
        {
            if (updateItemRequest == null)
            {
                throw new ArgumentException("The UpdateItem request should not be null.");
            }

            UpdateItemResponseType response = this.exchangeServiceBinding.UpdateItem(updateItemRequest);
            return response;
        }
        /// <summary>
        /// Update subject of specific items.
        /// </summary>
        /// <param name="itemIds">An array of folder identifiers.</param>
        /// <returns>If item updated successfully.</returns>
        protected bool UpdateItemSubject(params ItemIdType[] itemIds)
        {
            UpdateItemType updateRequest = new UpdateItemType();
            ItemChangeType[] itemChanges = new ItemChangeType[itemIds.Length];

            for (int index = 0; index < itemIds.Length; index++)
            {
                itemChanges[index] = new ItemChangeType();
                itemChanges[index].Item = itemIds[index];
                itemChanges[index].Updates = new ItemChangeDescriptionType[1];
                SetItemFieldType setItem = new SetItemFieldType();
                setItem.Item = new PathToUnindexedFieldType()
                {
                    FieldURI = UnindexedFieldURIType.itemSubject
                };
                setItem.Item1 = new ContactItemType()
                {
                    Subject = Common.GenerateResourceName(this.Site, "ItemSubjectUpdated", (uint)index),
                };
                itemChanges[index].Updates[0] = setItem;
            }

            updateRequest.ItemChanges = itemChanges;
            updateRequest.MessageDispositionSpecified = true;
            updateRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            updateRequest.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToAllAndSaveCopy;
            updateRequest.SendMeetingInvitationsOrCancellationsSpecified = true;

            UpdateItemResponseType updateItemResponse = this.COREAdapter.UpdateItem(updateRequest);

            // A Boolean indicates whether the response is a success.
            bool isSuccess = new bool();

            for (int index = 0; index < itemIds.Length; index++)
            {
                isSuccess = ResponseClassType.Success == updateItemResponse.ResponseMessages.Items[index].ResponseClass;

                if (isSuccess)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            return isSuccess;
        }
        public void MSOXWSMSG_S02_TC01_UpdateMessage()
        {
            #region Create message
            CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts);
            CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest);
            Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);

            // Save the ItemId of message responseMessageItem returned from the createItem response.
            ItemIdType itemIdType = new ItemIdType();
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;
            #endregion

            #region update ToRecipients property of the original message
            UpdateItemType updateItemRequest = new UpdateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,
                MessageDispositionSpecified = true,

                ItemChanges = new ItemChangeType[]
                {
                    new ItemChangeType
                    {
                        Item = itemIdType,                        

                        Updates = new ItemChangeDescriptionType[]
                        {
                            new SetItemFieldType
                            {
                                Item = new PathToUnindexedFieldType
                                {
                                    FieldURI = UnindexedFieldURIType.messageToRecipients
                                },

                                // Update the ToRecipients of message from Recipient1 to Recipient2.
                                Item1 = new MessageType
                                {
                                    ToRecipients = new EmailAddressType[]
                                    {
                                        new EmailAddressType
                                        {
                                            EmailAddress = this.Recipient2
                                        }
                                    }
                                }
                            }
                        }                   
                    }
                }
            };

            UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest);
            Site.Assert.IsTrue(this.VerifyResponse(updateItemResponse), @"Server should return success for creating the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);
            Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null.");

            // Save the ItemId of message responseMessageItem got from the UpdateItem response.
            if (this.firstItemOfFirstInfoItem != null)
            {
                Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
                itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
                itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;
            }

            #region Verify the requirements about UpdateItem
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R143");
        
            // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R143
            Site.CaptureRequirementIfIsNotNull(
                updateItemResponse,
                143,
                @"[In UpdateItem] The protocol client sends an UpdateItemSoapIn request WSDL message, and the protocol server responds with an UpdateItemSoapOut response WSDL message.");

            Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null.");
            
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R144");
        
            // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R144
            Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Success,
                this.infoItems[0].ResponseClass,
                144,
                @"[In UpdateItem] If the UpdateItem WSDL operation request is successful, the server returns an UpdateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.9.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the UpdateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". ");

            Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null.");
            
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R145");
        
            // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R145
            Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.NoError,
                this.infoItems[0].ResponseCode,
                145,
                @"[In UpdateItem] [A successful UpdateItem operation request returns an UpdateItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the UpdateItemResponseMessage element is set to ""NoError"". ");
            #endregion
            #endregion

            #region Get the updated message
            GetItemType getItemRequest = DefineGeneralGetItemRequestMessage(itemIdType, DefaultShapeNamesType.AllProperties);
            GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest);
            Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), @"Server should return success for getting the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(getItemResponse);
            Site.Assert.IsNotNull(this.infoItems, @"The GetItem response should contain one or more items of ItemInfoResponseMessageType.");
            ItemType updatedItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);
            Site.Assert.IsNotNull(updatedItem, @"The updated message should exist");

            string expectedValue = Common.GetConfigurationPropertyValue("Recipient2", this.Site);
            Site.Assert.AreEqual<string>(
                expectedValue.ToLower(),
                updatedItem.DisplayTo.ToLower(),
                string.Format("The expected value of the DisplayTo property is {0}. The actual value is {1}.", expectedValue, updatedItem.DisplayTo));
            #endregion

            #region Clean up Sender's drafts folder
            bool isClear = this.MSGSUTControlAdapter.CleanupFolders(
                Common.GetConfigurationPropertyValue("Sender", this.Site), 
                Common.GetConfigurationPropertyValue("SenderPassword", this.Site), 
                this.Domain, 
                this.Subject, 
                "drafts");
            Site.Assert.IsTrue(isClear, "Sender's drafts folder should be cleaned up.");
            #endregion
        }
        public void MSOXWSMSG_S06_TC01_OperateMultipleMessages()
        {
            #region Create multiple message
            string subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 0);
            string anotherSubject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 1);

            CreateItemType createItemRequest = new CreateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,

                // MessageDispositionSpecified value needs to be set.
                MessageDispositionSpecified = true,

                SavedItemFolderId = new TargetFolderIdType
                {
                    Item = new DistinguishedFolderIdType
                    {
                        Id = DistinguishedFolderIdNameType.drafts
                    }
                },

                Items = new NonEmptyArrayOfAllItemsType
                {
                    // Create an responseMessageItem with two MessageType instances.
                    Items = new MessageType[]
                    {
                        new MessageType
                        {
                            Sender = new SingleRecipientType
                            {
                                Item = new EmailAddressType
                                {
                                    EmailAddress = this.Sender
                                }                                
                            },

                            ToRecipients = new EmailAddressType[]
                            {
                                new EmailAddressType
                                {
                                     EmailAddress = this.Recipient1                              
                                }
                            },

                            Subject = subject,                                          
                        },

                        new MessageType
                        {
                             Sender = new SingleRecipientType
                            {
                                Item = new EmailAddressType
                                {
                                    EmailAddress = this.Sender
                                }                                
                            },

                            ToRecipients = new EmailAddressType[]
                            {
                                new EmailAddressType
                                {
                                     EmailAddress = this.Recipient2                               
                                }
                            },

                            Subject = anotherSubject,
                        }
                    }
                },
            };

            CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest);
            Site.Assert.IsTrue(this.VerifyMultipleResponse(createItemResponse), @"Server should return success for creating the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);
            Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null.");

            // Save the first ItemId of message responseMessageItem got from the createItem response.
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            ItemIdType itemIdType1 = new ItemIdType();            
            itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;

            // Save the second ItemId.
            this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0);
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null.");
            ItemIdType itemIdType2 = new ItemIdType();
            itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id;
            itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey;
            #endregion

            #region Get the multiple messages which created
            GetItemType getItemRequest = new GetItemType
            {
                // Set the two ItemIds got from CreateItem response.
                ItemIds = new ItemIdType[]
                {
                    itemIdType1,
                    itemIdType2
                },

                ItemShape = new ItemResponseShapeType
                {
                    BaseShape = DefaultShapeNamesType.AllProperties,
                }
            };

            GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest);
            Site.Assert.IsTrue(this.VerifyMultipleResponse(getItemResponse), @"Server should return success for creating the email messages.");
            #endregion

            #region Update the multiple messages which created
            UpdateItemType updateItemRequest = new UpdateItemType
            {
                MessageDisposition = MessageDispositionType.SaveOnly,

                // MessageDispositionSpecified value needs to be set.
                MessageDispositionSpecified = true,

                // Create two ItemChangeType instances.
                ItemChanges = new ItemChangeType[]
                {
                    new ItemChangeType
                    {
                        Item = itemIdType1,                        

                        Updates = new ItemChangeDescriptionType[]
                        {
                            new SetItemFieldType
                            {
                                Item = new PathToUnindexedFieldType
                                {
                                    FieldURI = UnindexedFieldURIType.messageToRecipients
                                },

                                // Update ToRecipients property of the first message.
                                Item1 = new MessageType
                                {
                                    ToRecipients = new EmailAddressType[]
                                    {
                                        new EmailAddressType
                                        {
                                            EmailAddress = this.Recipient2
                                        }
                                    }
                                }
                            },                           
                        }                   
                    },

                    new ItemChangeType
                    {
                        Item = itemIdType2,                        

                        Updates = new ItemChangeDescriptionType[]
                        {
                            new SetItemFieldType
                            {
                                Item = new PathToUnindexedFieldType
                                {
                                    FieldURI = UnindexedFieldURIType.messageToRecipients
                                },

                                // Update ToRecipients property of the second message.
                                Item1 = new MessageType
                                {
                                    ToRecipients = new EmailAddressType[]
                                    {
                                        new EmailAddressType
                                        {
                                            EmailAddress = this.Recipient1
                                        }
                                    }
                                }
                            },                           
                        }                   
                    }
                }
            };

            UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest);
            Site.Assert.IsTrue(this.VerifyMultipleResponse(updateItemResponse), @"Server should return success for updating the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(updateItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);
            Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null.");

            // Save the ItemId of the first message responseMessageItem got from the UpdateItem response.
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;

            // Save the ItemId of the second message responseMessageItem got from the UpdateItem response.
            this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0);
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null.");
            itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id;
            itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey;
            #endregion

            #region Copy the updated multiple message to junkemail
            CopyItemType copyItemRequest = new CopyItemType
            {
                ItemIds = new ItemIdType[]
                {
                    itemIdType1,
                    itemIdType2,
                },

                // Copy the message to junk email folder.
                ToFolderId = new TargetFolderIdType
                {
                    Item = new DistinguishedFolderIdType
                    {
                        Id = DistinguishedFolderIdNameType.junkemail
                    }
                }
            };

            CopyItemResponseType copyItemResponse = this.MSGAdapter.CopyItem(copyItemRequest);
            Site.Assert.IsTrue(this.VerifyMultipleResponse(copyItemResponse), @"Server should return success for copying the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(copyItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);
            Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null.");

            // Save the ItemId of the first message responseMessageItem got from the CopyItem response.
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            ItemIdType copyItemIdType1 = new ItemIdType();
            copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;

            // Save the ItemId of the second message responseMessageItem got from the CopyItem response.
            this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0);
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null.");
            ItemIdType copyItemIdType2 = new ItemIdType();
            copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id;
            copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey;
            #endregion

            #region Move the copied multiple message from junkemail to deleteditems
            MoveItemType moveItemRequest = new MoveItemType
            {
                // Set to copied message responseMessageItem id.
                ItemIds = new ItemIdType[]
                {
                    copyItemIdType1,
                    copyItemIdType2
                },

                // Move the copied messages to deleted items folder.
                ToFolderId = new TargetFolderIdType
                {
                    Item = new DistinguishedFolderIdType
                    {
                        Id = DistinguishedFolderIdNameType.deleteditems
                    }
                }
            };

            MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest);
            Site.Assert.IsTrue(this.VerifyMultipleResponse(moveItemResponse), @"Server should return success for moving the email messages.");
            this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(moveItemResponse);
            this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0);
            Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null.");

            // Save the ItemId of the first message responseMessageItem got from the MoveItem response.
            Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null.");
            copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id;
            copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey;

            // Save the ItemId of the second message responseMessageItem got from the MoveItem response.
            this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0);
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null.");
            Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null.");
            copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id;
            copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey;
            #endregion

            #region Send multiple messages
            SendItemType sendItemRequest = new SendItemType
            {
                // Set to the two updated messages' ItemIds.
                ItemIds = new ItemIdType[]
                {
                    itemIdType1,
                    itemIdType2
                },

                // Do not save copy.
                SaveItemToFolder = false,
            };

            SendItemResponseType sendItemResponse = this.MSGAdapter.SendItem(sendItemRequest);
            Site.Assert.IsTrue(this.VerifyMultipleResponse(sendItemResponse), @"Server should return success for sending the email messages.");
            #endregion

            #region Delete the copied messages
            DeleteItemType deleteItemRequest = new DeleteItemType
            {
                // Set to the two copied messages' ItemIds.
                ItemIds = new ItemIdType[]
                {
                   copyItemIdType1,
                   copyItemIdType2
                }
            };

            DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest);
            Site.Assert.IsTrue(this.VerifyMultipleResponse(deleteItemResponse), @"Server should return success for deleting the email messages.");
            #endregion

            #region Clean up Recipient1's and Recipient2's inbox folders
            bool isClear = this.MSGSUTControlAdapter.CleanupFolders(
                Common.GetConfigurationPropertyValue("Recipient2", this.Site), 
                Common.GetConfigurationPropertyValue("Recipient2Password", this.Site), 
                this.Domain, 
                subject, 
                "inbox");
            Site.Assert.IsTrue(isClear, "Recipient2's inbox folder should be cleaned up.");

            isClear = this.MSGSUTControlAdapter.CleanupFolders(
                Common.GetConfigurationPropertyValue("Recipient1", this.Site), 
                Common.GetConfigurationPropertyValue("Recipient1Password", this.Site), 
                this.Domain, 
                anotherSubject, 
                "inbox");
            Site.Assert.IsTrue(isClear, "Recipient1's inbox folder should be cleaned up.");
            #endregion
        }
        /// <summary>
        /// Updates Task items on the server.
        /// </summary>
        /// <param name="updateItemRequest">Specifies a request to update Task items on the server.</param>
        /// <returns>A response to this operation request.</returns>
        public UpdateItemResponseType UpdateItem(UpdateItemType updateItemRequest)
        {
            UpdateItemResponseType updateItemResponse = this.exchangeServiceBinding.UpdateItem(updateItemRequest);
            Site.Assert.IsNotNull(updateItemResponse, "If the operation is successful, the response should not be null.");

            // Verify the update item operation.
            this.VerifyUpdateItemOperation(updateItemResponse, this.exchangeServiceBinding.IsSchemaValidated);

            // Verify Soap version requirements.
            this.VerifySoapVersion();

            // Verify transport requirements.
            this.VerifyTransportType();

            return updateItemResponse;
        }
Exemplo n.º 18
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateItem(UpdateItemType UpdateItem1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateItem", new object[] {
             UpdateItem1}, callback, asyncState);
 }
        public void MSOXWSCONT_S02_TC01_UpdateContactItem()
        {
            #region Step 1:Create the contact item.
            // Create a contact item.
            ContactItemType item = this.BuildContactItemWithRequiredProperties();
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(item);

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

            #region Step 2:Update the contact item.
            UpdateItemType updateItemRequest = new UpdateItemType()
            {
                // Configure ItemIds.
                ItemChanges = new ItemChangeType[]
                {
                    new ItemChangeType()
                    {
                        Item = this.ExistContactItems[0],

                        Updates = new ItemChangeDescriptionType[]
                        {
                            new SetItemFieldType()
                            {
                                Item = new PathToUnindexedFieldType()
                                {
                                    FieldURI = UnindexedFieldURIType.contactsFileAs
                                },

                                Item1 = new ContactItemType()
                                {
                                    FileAs = FileAsMappingType.LastFirstCompany.ToString()
                                }
                            }
                        }
                    }
                },

                ConflictResolution = ConflictResolutionType.AlwaysOverwrite
            };

            UpdateItemResponseType updateItemResponse = new UpdateItemResponseType();

            // Invoke UpdateItem operation.
            updateItemResponse = this.CONTAdapter.UpdateItem(updateItemRequest);

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

            #region Step 3:Get the contact item.
            // The contact item to get.
            ItemIdType[] itemArray = new ItemIdType[this.ExistContactItems.Count];
            this.ExistContactItems.CopyTo(itemArray, 0);

            GetItemResponseType getItemResponse = this.CallGetItemOperation(itemArray);

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

            ContactItemType[] contacts = Common.GetItemsFromInfoResponse<ContactItemType>(getItemResponse);

            Site.Assert.AreEqual<int>(
                1,
                contacts.Length,
                string.Format(
                    "The count of items from response should be 1, actual: '{0}'.", contacts.Length));

            Site.Assert.AreEqual<string>(
                FileAsMappingType.LastFirstCompany.ToString(),
                contacts[0].FileAs,
                string.Format(
                    "The FileAs property should be updated as set. Expected value: {0}, actual value: {1}", FileAsMappingType.LastFirstCompany.ToString(), contacts[0].FileAs));
            #endregion
        }
Exemplo n.º 20
0
 /// <remarks/>
 public void UpdateItemAsync(UpdateItemType UpdateItem1, object userState)
 {
     if ((this.UpdateItemOperationCompleted == null))
     {
         this.UpdateItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateItemOperationCompleted);
     }
     this.InvokeAsync("UpdateItem", new object[] {
             UpdateItem1}, this.UpdateItemOperationCompleted, userState);
 }
        public void MSOXWSMTGS_S02_TC11_UpdateItemErrorMessageDispositionRequired()
        {
            #region Create a message without setting MessageDisposition element.
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { new MessageType() };
            createItemRequest.Items.Items[0].Subject = this.Subject;
            DistinguishedFolderIdType folderIdForCreateItems = new DistinguishedFolderIdType();
            folderIdForCreateItems.Id = DistinguishedFolderIdNameType.drafts;
            createItemRequest.SavedItemFolderId = new TargetFolderIdType();
            createItemRequest.SavedItemFolderId.Item = folderIdForCreateItems;
            CreateItemResponseType createItemResponse = this.MTGSAdapter.CreateItem(createItemRequest);

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1241
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                createItemResponse.ResponseMessages.Items[0].ResponseClass,
                1241,
                @"[In Messages] ErrorMessageDispositionRequired:This error code MUST be returned under the following conditions: 
                  When the item that is being created or updated is a MessageType object. 
                  [For the CancelCalendarItemType, AcceptItemType, DeclineItemType, or TentativelyAcceptItemType response objects.]");
            #endregion

            #region Create a message with setting MessageDisposition element.
            createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            createItemRequest.MessageDispositionSpecified = true;
            createItemResponse = this.MTGSAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);
            #endregion

            #region Update the message without setting MessageDisposition element.
            MessageType messageUpdate = new MessageType();
            messageUpdate.Subject = this.SubjectUpdate;

            UpdateItemType updateItemRequest = new UpdateItemType();
            updateItemRequest.ItemChanges = new ItemChangeType[1];
            PathToUnindexedFieldType pathToUnindexedField = new PathToUnindexedFieldType();
            pathToUnindexedField.FieldURI = UnindexedFieldURIType.itemSubject;
            SetItemFieldType setItemField = new SetItemFieldType();
            setItemField.Item = pathToUnindexedField;
            setItemField.Item1 = messageUpdate;
            ItemChangeType itemChange = new ItemChangeType();
            itemChange.Item = (createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType).Items.Items[0].ItemId;
            itemChange.Updates = new ItemChangeDescriptionType[] { setItemField };
            updateItemRequest.ItemChanges[0] = itemChange;
            UpdateItemResponseType updateItemResponse = this.MTGSAdapter.UpdateItem(updateItemRequest);

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1237
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                updateItemResponse.ResponseMessages.Items[0].ResponseClass,
                1237,
                @"[In Messages] If the request is unsuccessful, the UpdateItem operation returns an UpdateItemResponse element with the ResponseClass attribute of the UpdateItemResponseMessage element set to ""Error"". ");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1240
            this.Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorMessageDispositionRequired,
                updateItemResponse.ResponseMessages.Items[0].ResponseCode,
                1240,
                @"[In Messages] ErrorMessageDispositionRequired: Occurs if the MessageDisposition property is not set. ");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1241
            this.Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorMessageDispositionRequired,
                updateItemResponse.ResponseMessages.Items[0].ResponseCode,
                1241,
                @"[In Messages] ErrorMessageDispositionRequired:This error code MUST be returned under the following conditions: 
                  When the item that is being created or updated is a MessageType object. 
                  [For the CancelCalendarItemType, AcceptItemType, DeclineItemType, or TentativelyAcceptItemType response objects.]");
            #endregion

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