Пример #1
0
        /// <summary>
        /// Get the UploadItemsResponseMessageType response of UploadItems operation when this operation executes unsuccessfully.
        /// </summary>
        /// <param name="parentFolderId">Specifies the target folder in which to place the upload item.</param>
        /// <param name="createAction">Specifies the action for uploading items to the folder.</param>
        /// <returns>The array of UploadItemsResponseMessageType response.</returns>
        protected UploadItemsResponseMessageType[] UploadInvalidItems(Collection <string> parentFolderId, CreateActionType createAction)
        {
            #region Get the exported items and parent folder ID.
            // Get the exported items which is prepared for uploading.
            ExportItemsResponseMessageType[] exportedItem = this.ExportItems(false);
            #endregion

            #region Call UploadItems operation to upload the items that exported in last step to the server.
            // Initialize the upload items using the data of previous export items, and set that item CreateAction to a value of CreateActionType.
            UploadItemsType uploadInvalidItems = new UploadItemsType();
            uploadInvalidItems.Items = new UploadItemType[4];

            // The ID attribute of ItemId is empty.
            uploadInvalidItems.Items[0] = TestSuiteHelper.GenerateUploadItem(
                string.Empty,
                null,
                exportedItem[0].Data,
                parentFolderId[0],
                createAction);

            // The ID attribute of ItemId is valid and the ChangeKey is invalid.
            uploadInvalidItems.Items[1] = TestSuiteHelper.GenerateUploadItem(
                exportedItem[1].ItemId.Id,
                InvalidChangeKey,
                exportedItem[1].Data,
                parentFolderId[1],
                createAction);

            // The ID attribute of ItemId is invalid and the ChangeKey is null.
            uploadInvalidItems.Items[2] = TestSuiteHelper.GenerateUploadItem(
                InvalidItemId,
                null,
                exportedItem[2].Data,
                parentFolderId[2],
                createAction);

            // The ID attribute of ItemId is invalid and the ChangeKey is null.
            uploadInvalidItems.Items[3] = TestSuiteHelper.GenerateUploadItem(
                InvalidItemId,
                null,
                exportedItem[3].Data,
                parentFolderId[3],
                createAction);

            // Call UploadItems operation.
            UploadItemsResponseType uploadItemsResponse = this.BTRFAdapter.UploadItems(uploadInvalidItems);

            // Check whether the ExportItems operation is executed successfully.
            foreach (UploadItemsResponseMessageType responseMessage in uploadItemsResponse.ResponseMessages.Items)
            {
                Site.Assert.AreEqual <ResponseClassType>(
                    ResponseClassType.Error,
                    responseMessage.ResponseClass,
                    string.Format(
                        @"The UploadItems operation should be unsuccessful. Expected response code: {0}, actual response code: {1}",
                        ResponseClassType.Error,
                        responseMessage.ResponseClass));
            }
            #endregion

            #region Verify the UploadItemsResponseType related requirements
            // Verify the UploadItemsResponseType related requirements.
            this.VerifyUploadItemsErrorResponse(uploadItemsResponse);
            #endregion

            #region Call GetResponseMessages to get the UploadItemsResponseMessageType items.
            // Get the UploadItemsResponseMessageType items.
            UploadItemsResponseMessageType[] uploadItemsResponseMessages = TestSuiteHelper.GetResponseMessages <UploadItemsResponseMessageType>(uploadItemsResponse);

            return(uploadItemsResponseMessages);

            #endregion
        }
        public void MSOXWSBTRF_S01_TC05_ExportAndUploadItems_Update_Fail()
        {
            #region Get the exported items.
            // Get the exported items which are prepared for uploading.
            ExportItemsResponseMessageType[] exportedItem = this.ExportItems(false);
            #endregion

            #region Create a new folder to place the upload item.
            // Create another sub folder.
            string[] subFolderIds = new string[this.ParentFolderType.Count];
            for (int i = 0; i < subFolderIds.Length; i++)
            {
                // Generate the folder name.
                string folderName = Common.GenerateResourceName(this.Site, this.ParentFolderType[i] + "NewFolder");

                // Create sub folder in the specified parent folder
                subFolderIds[i] = this.CreateSubFolder(this.ParentFolderType[i], folderName);
                Site.Assert.IsNotNull(
                    subFolderIds[i],
                    string.Format(
                        "The sub folder named '{0}' under '{1}' should be created successfully.",
                        folderName,
                        this.ParentFolderType[i].ToString()));
            }
            #endregion

            #region Call UploadItems operation with CreateAction set to Update and the ParentFolderId set to the new created sub folder.
            // Initialize the uploaded items using the previous exported items, set the item's CreateAction to Update and the ParentFolderId to the sub folder.
            UploadItemsType uploadItemsWithChangedParentFolderId = new UploadItemsType();
            uploadItemsWithChangedParentFolderId.Items = new UploadItemType[this.ItemCount];
            for (int i = 0; i < uploadItemsWithChangedParentFolderId.Items.Length; i++)
            {
                uploadItemsWithChangedParentFolderId.Items[i] = TestSuiteHelper.GenerateUploadItem(
                    exportedItem[i].ItemId.Id,
                    exportedItem[i].ItemId.ChangeKey,
                    exportedItem[i].Data,
                    subFolderIds[i],
                    CreateActionType.Update);
            }

            // Call UploadItems operation.
            UploadItemsResponseType uploadItemsWithChangedParentFolderIdResponse = this.BTRFAdapter.UploadItems(uploadItemsWithChangedParentFolderId);

            // Check whether the ExportItems operation is executed successfully.
            foreach (UploadItemsResponseMessageType responseMessage in uploadItemsWithChangedParentFolderIdResponse.ResponseMessages.Items)
            {
                Site.Assert.AreEqual <ResponseClassType>(
                    ResponseClassType.Error,
                    responseMessage.ResponseClass,
                    string.Format(
                        @"The ExportItems operation should be unsuccessful. Expected response code: {0}, actual response code: {1}",
                        ResponseClassType.Error,
                        responseMessage.ResponseClass));
            }
            #endregion

            #region Verify UploadItems related requirements.
            // Verify UploadItems related requirements.
            this.VerifyUploadItemsErrorResponse(uploadItemsWithChangedParentFolderIdResponse);

            // If the ResponseClass property equals Error, then MS-OXWSBTRF_R231 can be captured
            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R231.");

            // Verify MS-OXWSBTRF requirement: MS-OXWSBTRF_R231
            Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.ErrorItemNotFound,
                uploadItemsWithChangedParentFolderIdResponse.ResponseMessages.Items[0].ResponseCode,
                231,
                @"[In CreateActionType Simple Type][Update] 
                if the target item is not in the original folder specified by the <ParentFolderId> element in the UploadItemType complex type, 
                an ErrorItemNotFound error code MUST be returned in the UploadItemsResponseMessageType complex type.");
            #endregion

            #region Call UploadItems operation with CreateAction set to Update and the ItemId set to invalid value.
            // Call UploadItemsFail method to upload three kinds of items and set the CreateAction to Update:
            // 1.The ID attribute of ItemId is empty;
            // 2.The ID attribute of ItemId is valid and the ChangeKey is invalid;
            // 3.The ID attribute of ItemId is invalid and the ChangeKey is null.
            this.UploadInvalidItems(this.OriginalFolderId, CreateActionType.Update);
            #endregion
        }
Пример #3
0
        /// <summary>
        /// Get the UploadItemsResponseMessageType response of UploadItems operation when this operation executes successfully.
        /// </summary>
        /// <param name="exportedItems">The items exported from server.</param>
        /// <param name="parentFolderId">Specifies the target folder in which to place the upload item.</param>
        /// <param name="createAction">Specifies the action for uploading items to the folder.</param>
        /// <param name="isAssociatedSpecified">A Boolean value specifies whether IsAssociated attribute is specified.</param>
        /// <param name="isAssociated">Specifies the value of the IsAssociated attribute.</param>
        /// <param name="configureSOAPHeader">A Boolean value specifies whether configuring the SOAP header before calling operations.</param>
        /// <returns>The array of UploadItemsResponseMessageType response.</returns>
        protected UploadItemsResponseMessageType[] UploadItems(
            ExportItemsResponseMessageType[] exportedItems,
            Collection <string> parentFolderId,
            CreateActionType createAction,
            bool isAssociatedSpecified,
            bool isAssociated,
            bool configureSOAPHeader)
        {
            #region Call UploadItems operation to upload the items that exported in last step to the server.
            // Initialize the upload items using the data of previous exported items, and set that item CreateAction to a value of CreateActionType.
            UploadItemsType uploadItems = new UploadItemsType();
            uploadItems.Items = new UploadItemType[this.ItemCount];
            for (int i = 0; i < uploadItems.Items.Length; i++)
            {
                uploadItems.Items[i] = TestSuiteHelper.GenerateUploadItem(
                    exportedItems[i].ItemId.Id,
                    exportedItems[i].ItemId.ChangeKey,
                    exportedItems[i].Data,
                    parentFolderId[i],
                    createAction);
                uploadItems.Items[i].IsAssociatedSpecified = isAssociatedSpecified;
                if (uploadItems.Items[i].IsAssociatedSpecified)
                {
                    uploadItems.Items[i].IsAssociated = isAssociated;
                }
            }

            // Call UploadItems operation.
            UploadItemsResponseType uploadItemsResponse = this.BTRFAdapter.UploadItems(uploadItems);

            // Check whether the operation is executed successfully.
            foreach (UploadItemsResponseMessageType uploadResponse in uploadItemsResponse.ResponseMessages.Items)
            {
                Site.Assert.AreEqual <ResponseClassType>(
                    ResponseClassType.Success,
                    uploadResponse.ResponseClass,
                    string.Format(
                        @"The UploadItems operation should be successful. Expected response code: {0}, actual response code: {1}",
                        ResponseClassType.Error,
                        uploadResponse.ResponseClass));
            }

            // If the operation executes successfully, the items in UploadItems response should be equal to the value of ItemCount
            Site.Assert.AreEqual <int>(
                uploadItemsResponse.ResponseMessages.Items.Length,
                this.ItemCount,
                string.Format(
                    "The uploadItems response should contain {0} items, actually, it contains {1}",
                    this.ItemCount,
                    uploadItemsResponse.ResponseMessages.Items.Length));
            #endregion

            #region Verify the UploadItemsResponseType related requirements
            // Verify the UploadItemsResponseType related requirements.
            this.VerifyUploadItemsSuccessResponse(uploadItemsResponse);
            #endregion

            #region Call GetResponseMessages to get the UploadItemsResponseMessageType items.
            // Get the UploadItemsResponseMessageType items.
            UploadItemsResponseMessageType[] uploadItemsResponseMessages = TestSuiteHelper.GetResponseMessages <UploadItemsResponseMessageType>(uploadItemsResponse);

            return(uploadItemsResponseMessages);

            #endregion
        }