Exemplo n.º 1
0
        private void RemoveRecurrenceExceptions(Appointment appointmentToUpdate)
        {
            ItemChangeType itemUpdates = new ItemChangeType();

            ItemIdType itemId = new ItemIdType();

            itemId.Id        = appointmentToUpdate.Attributes[ExchangeIdAttribute];
            itemId.ChangeKey = appointmentToUpdate.Attributes[ExchangeChangeKeyAttribute];

            itemUpdates.Item = itemId;

            PathToUnindexedFieldType deletedOccurrencesPath = new PathToUnindexedFieldType();

            deletedOccurrencesPath.FieldURI = UnindexedFieldURIType.calendarRecurrence;

            DeleteItemFieldType deletedOccurrencesUpdate = new DeleteItemFieldType();

            deletedOccurrencesUpdate.Item = deletedOccurrencesPath;

            // To reset the deleted and modified occurrences we must
            // remove the recurrence rule and then immediately restore it
            itemUpdates.Updates = new ItemChangeDescriptionType[] { deletedOccurrencesUpdate, GetRecurrenceUpdate(appointmentToUpdate) };
            UpdateCalendarItem(new ItemChangeType[] { itemUpdates });
        }
		private void RemoveRecurrenceExceptions(Appointment appointmentToUpdate)
		{
			ItemChangeType itemUpdates = new ItemChangeType();

			ItemIdType itemId = new ItemIdType();
			itemId.Id = appointmentToUpdate.Attributes[ExchangeIdAttribute];
			itemId.ChangeKey = appointmentToUpdate.Attributes[ExchangeChangeKeyAttribute];

			itemUpdates.Item = itemId;

			PathToUnindexedFieldType deletedOccurrencesPath = new PathToUnindexedFieldType();
			deletedOccurrencesPath.FieldURI = UnindexedFieldURIType.calendarRecurrence;

			DeleteItemFieldType deletedOccurrencesUpdate = new DeleteItemFieldType();
			deletedOccurrencesUpdate.Item = deletedOccurrencesPath;

			// To reset the deleted and modified occurrences we must
			// remove the recurrence rule and then immediately restore it
			itemUpdates.Updates = new ItemChangeDescriptionType[] { deletedOccurrencesUpdate, GetRecurrenceUpdate(appointmentToUpdate) };
			UpdateCalendarItem(new ItemChangeType[] { itemUpdates });
		}
        public void MSOXWSCORE_S01_TC04_UpdateItemSuccessfully()
        {
            #region Step 1: Create the item.
            ItemType item = new ItemType();
            ItemIdType[] createdItemIds = this.CreateItemWithMinimumElements(item);
            #endregion

            #region Step 2: Update the item, using AppendToItemField element.
            UpdateItemResponseType updateItemResponse;
            ItemChangeType[] itemChanges;

            itemChanges = new ItemChangeType[1];
            itemChanges[0] = new ItemChangeType();

            // Update the created item.
            itemChanges[0].Item = createdItemIds[0];
            itemChanges[0].Updates = new ItemChangeDescriptionType[1];
            AppendToItemFieldType append = new AppendToItemFieldType();
            append.Item = new PathToUnindexedFieldType()
            {
                FieldURI = UnindexedFieldURIType.itemBody
            };
            append.Item1 = new ItemType()
            {
                Body = new BodyType()
                {
                    BodyType1 = BodyTypeType.Text,
                    Value = TestSuiteHelper.BodyForBaseItem
                }
            };
            itemChanges[0].Updates[0] = append;

            // Call UpdateItem to update the body of the created item, by using ItemId in CreateItem response.
            updateItemResponse = this.CallUpdateItemOperation(
                DistinguishedFolderIdNameType.drafts,
                true,
                itemChanges);

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

            ItemIdType[] updatedItemIds = createdItemIds;

            // One updated item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 updatedItemIds.GetLength(0),
                 "One updated item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 updatedItemIds.GetLength(0));

            Site.Assert.IsTrue(this.IsSchemaValidated, "The schema should be validated.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R508
            // The schema is validated and the response is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                updateItemResponse,
                508,
                @"[In m:UpdateItemResponseType Complex Type] The UpdateItemResponseType complex type extends the BaseResponseMessageType complex type ([MS-OXWSCDATA] section 2.2.4.16).");

            UpdateItemResponseMessageType updateItemResponseMessage = updateItemResponse.ResponseMessages.Items[0] as UpdateItemResponseMessageType;

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R158
            this.Site.CaptureRequirementIfIsTrue(
                updateItemResponseMessage.Items.Items[0].ItemId.Id == createdItemIds[0].Id
                && updateItemResponseMessage.Items.Items[0].ItemId.ChangeKey != createdItemIds[0].ChangeKey,
                158,
                @"[In t:ItemIdType Complex Type] [The attribute ""ChangeKey""] Specifies a change key.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R58
            // The schema is validated and the response is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                updateItemResponseMessage,
                58,
                @"[In m:UpdateItemResponseMessageType Complex Type] The UpdateItemResponseMessageType complex type extends the ItemInfoResponseMessageType complex type ([MS-OXWSCDATA] section 2.2.4.37).");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCDATA_R1586
            // The schema is validated and the response is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                updateItemResponseMessage,
                "MS-OXWSCDATA",
                1586,
                @"[In m:ArrayOfResponseMessagesType Complex Type] The element ""UpdateItemResponseMessage"" is ""m:UpdateItemResponseMessageType"" type ([MS-OXWSCORE] section 2.2.4.6).");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCDATA_R1040
            // The schema is validated and the response is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                updateItemResponseMessage,
                "MS-OXWSCDATA",
                1040,
                @"[In m:ArrayOfResponseMessagesType Complex Type] The element ""UpdateItemResponseMessage"" with type ""m:UpdateItemResponseMessageType"" specifies the response message for the UpdateItem operation ([MS-OXWSCORE] section 3.1.4.9).");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1305
            // The schema is validated and the conflict result is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                updateItemResponseMessage.ConflictResults,
                1305,
                @"[In m:UpdateItemResponseMessageType Complex Type] The type of ConflictResults is t:ConflictResultsType (section 2.2.4.7).");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1306
            // The schema is validated, so this requirement can be captured.
            this.Site.CaptureRequirement(
                1306,
                @"[In t:ConflictResultsType Complex Type] The type of Count is xs:int [XMLSCHEMA2].");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R65
            // The schema is validated, so this requirement can be captured.
            this.Site.CaptureRequirement(
                65,
                @"[In t:ConflictResultsType Complex Type] [The element ""Count""] Specifies an integer value that indicates the number of conflicts in an UpdateItem operation response.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R61
            // The schema is validated and the conflict result is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                updateItemResponseMessage.ConflictResults,
                61,
                @"[In m:UpdateItemResponseMessageType Complex Type] [The element ""ConflictResults""] Specifies the number of conflicts in the result of a single call.");

            #endregion

            #region Step 3: Get the item to check the updates.
            // Call GetItem to get the updated item, by using updatedItemIds in UpdateItem response.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(updatedItemIds);

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

            ItemIdType[] getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse);

            // One item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 getItemIds.GetLength(0),
                 "One item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));

            ItemInfoResponseMessageType getItemResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;

            Site.Assert.AreEqual<BodyTypeType>(
                append.Item1.Body.BodyType1,
                getItemResponseMessage.Items.Items[0].Body.BodyType1,
                string.Format(
                "The value of BodyType1 should be {0}, actual {1}.",
                append.Item1.Body.BodyType1,
                getItemResponseMessage.Items.Items[0].Body.BodyType1));

            Site.Assert.AreEqual<string>(
                append.Item1.Body.Value,
                getItemResponseMessage.Items.Items[0].Body.Value,
                string.Format(
                "The value of Body should be {0}, actual {1}.",
                append.Item1.Body.Value,
                getItemResponseMessage.Items.Items[0].Body.Value));

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R555
            // The value of BodyType1 from response is equal to the value of BodyType1 from the request,
            // and the value of Body from response is equal to the value of Body from request,
            // so this requirement can be captured.
            this.Site.CaptureRequirement(
                555,
                @"[In t:NonEmptyArrayOfItemChangeDescriptionsType Complex Type] [The element ""AppendToItemField""] Specifies data to append to a single property of an item during an UpdateItem operation.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R561
            // The value of BodyType1 from response is equal to the value of BodyType1 from the request,
            // and the value of Body from response is equal to the value of Body from request,
            // so this requirement can be captured.
            this.Site.CaptureRequirement(
                561,
                @"[In t:NonEmptyArrayOfItemChangesType Complex Type] [The element ""ItemChange""] Specifies an item identifier and the updates to apply to the item.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R514
            // Because the value of SavedItemFolderId cannot be compared with the parent folder id from response.
            // So if the updated item can be gotten successfully, this requirement can be captured.
            this.Site.CaptureRequirement(
                514,
                @"[In m:UpdateItemType Complex Type] [The element ""SavedItemFolderId""] Specifies the target folder for saved items.");
            #endregion

            #region Step 4: Update the item, using SetItemField element.
            itemChanges = new ItemChangeType[1];
            itemChanges[0] = new ItemChangeType();
            itemChanges[0].Item = getItemIds[0];
            itemChanges[0].Updates = new ItemChangeDescriptionType[1];
            SetItemFieldType setItem = new SetItemFieldType();
            setItem.Item = new PathToUnindexedFieldType()
            {
                FieldURI = UnindexedFieldURIType.itemSubject
            };
            setItem.Item1 = new ItemType()
            {
                Subject = Common.GenerateResourceName(
                    this.Site,
                    TestSuiteHelper.SubjectForUpdateItem)
            };
            itemChanges[0].Updates[0] = setItem;

            // Call UpdateItem to update the subject of the created item, by using ItemId in CreateItem response.
            updateItemResponse = this.CallUpdateItemOperation(
                DistinguishedFolderIdNameType.drafts,
                true,
                itemChanges);

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

            updatedItemIds = Common.GetItemIdsFromInfoResponse(updateItemResponse);

            // One updated item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 updatedItemIds.GetLength(0),
                 "One updated item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 updatedItemIds.GetLength(0));

            #endregion

            #region Step 5: Get the item to check the updates.

            // Call GetItem to get the updated item in the Inbox folder, by using updatedItemIds in UpdateItem response.
            getItemResponse = this.CallGetItemOperation(updatedItemIds);

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

            getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse);

            // One item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 getItemIds.GetLength(0),
                 "One item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));

            getItemResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R556
            this.Site.CaptureRequirementIfAreEqual<string>(
                setItem.Item1.Subject,
                getItemResponseMessage.Items.Items[0].Subject,
                556,
                @"[In t:NonEmptyArrayOfItemChangeDescriptionsType Complex Type] [The element ""SetItemField""] Specifies an update to a single property of an item in an UpdateItem operation.");
            #endregion

            #region Step 6: Update the item, using DeleteItemField element.
            itemChanges = new ItemChangeType[1];
            itemChanges[0] = new ItemChangeType();
            itemChanges[0].Item = getItemIds[0];
            itemChanges[0].Updates = new ItemChangeDescriptionType[1];
            DeleteItemFieldType delField = new DeleteItemFieldType();
            delField.Item = new PathToUnindexedFieldType()
            {
                FieldURI = UnindexedFieldURIType.itemBody
            };
            itemChanges[0].Updates[0] = delField;

            // Call UpdateItem to delete the body value of the created item, by using ItemId in CreateItem response.
            updateItemResponse = this.CallUpdateItemOperation(
                DistinguishedFolderIdNameType.drafts,
                true,
                itemChanges);

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

            updatedItemIds = Common.GetItemIdsFromInfoResponse(updateItemResponse);

            // One updated item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 updatedItemIds.GetLength(0),
                 "One updated item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 updatedItemIds.GetLength(0));

            #endregion

            #region Step 7: Get the item to check the updates
            // Call GetItem to get the updated item in the Inbox folder, by using updatedItemIds in UpdateItem response.
            getItemResponse = this.CallGetItemOperation(updatedItemIds);

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

            getItemResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R557");
        
            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R557
            // The value of Body is null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNull(
                getItemResponseMessage.Items.Items[0].Body.Value,
                557,
                @"[In t:NonEmptyArrayOfItemChangeDescriptionsType Complex Type] [The element ""DeleteItemField"" with type ""t:DeleteItemFieldType""] Specifies an operation to delete a given property from an item during an UpdateItem operation.");
            #endregion
        }