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
        }
        public void MSOXWSBTRF_S01_TC01_ExportAndUploadItems_CreateNew_Success()
        {
            #region Prerequisites.
            // In the initialize step, multiple items in the specified parent folder have been created.
            // If that step executes successfully, the count of CreatedItemId list should be equal to the count of OriginalFolderId list.
            Site.Assert.AreEqual <int>(
                this.CreatedItemId.Count,
                this.OriginalFolderId.Count,
                string.Format(
                    "The exportedItemIds array should contain {0} item ids, actually, it contains {1}",
                    this.OriginalFolderId.Count,
                    this.CreatedItemId.Count));
            #endregion

            #region Call ExportItems operation to export the items from the server.
            // Initialize three ExportItemsType instances.
            ExportItemsType exportItems = new ExportItemsType();

            // Initialize four ItemIdType instances with three different situations to cover the case:
            // 1. The ChangeKey is not present;
            // 2. If the ChangeKey attribute of the ItemIdType complex type is present, its value MUST be either valid or NULL.
            exportItems.ItemIds = new ItemIdType[4]
            {
                new ItemIdType
                {
                    // The ChangeKey is not present.
                    Id = this.CreatedItemId[0].Id,
                },
                new ItemIdType
                {
                    // The ChangeKey is null.
                    Id        = this.CreatedItemId[1].Id,
                    ChangeKey = null
                },
                new ItemIdType
                {
                    // The ChangeKey is valid.
                    Id        = this.CreatedItemId[2].Id,
                    ChangeKey = this.CreatedItemId[2].ChangeKey
                },
                new ItemIdType
                {
                    // The ChangeKey is not present.
                    Id = this.CreatedItemId[3].Id,
                }
            };

            // Call ExportItems operation.
            ExportItemsResponseType exportItemsResponse = this.BTRFAdapter.ExportItems(exportItems);
            Site.Assert.IsNotNull(exportItemsResponse, "The ExportItems response should not be null.");

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

            // If the operation executes successfully, the count of items in ExportItems response should be equal to the items in ExportItems request.
            Site.Assert.AreEqual <int>(
                exportItemsResponse.ResponseMessages.Items.Length,
                exportItems.ItemIds.Length,
                string.Format(
                    "The exportItems response should contain {0} items, actually, it contains {1}",
                    exportItems.ItemIds.Length,
                    exportItemsResponse.ResponseMessages.Items.Length));

            // Verify ManagementRole part of ExportItems operation
            this.VerifyManagementRolePart();
            #endregion

            #region Verify the ExportItems response related requirements
            // Verify the ExportItemsResponseType related requirements.
            this.VerifyExportItemsSuccessResponse(exportItemsResponse);

            // If the id in ExportItems request is same with the id in ExportItems response, then MS-OXWSBTRF_R169 and MS-OXWSBTRF_R182 can be captured.
            bool isSameItemId = false;
            for (int i = 0; i < exportItemsResponse.ResponseMessages.Items.Length; i++)
            {
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "The exported item's id: '{0}' should be same with the created item's id: {1}.",
                    (exportItemsResponse.ResponseMessages.Items[i] as ExportItemsResponseMessageType).ItemId.Id,
                    this.CreatedItemId[i].Id);
                if ((exportItemsResponse.ResponseMessages.Items[i] as ExportItemsResponseMessageType).ItemId.Id == this.CreatedItemId[i].Id)
                {
                    isSameItemId = true;
                }
                else
                {
                    isSameItemId = false;
                    break;
                }
            }

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

            // Verify requirement MS-OXWSBTRF_R169
            Site.CaptureRequirementIfIsTrue(
                isSameItemId,
                169,
                @"[In m:ExportItemsResponseMessageType Complex Type][ItemId] specifies the item identifier of a single exported item.");

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

            // Verify requirement MS-OXWSBTRF_R182
            Site.CaptureRequirementIfIsTrue(
                isSameItemId,
                182,
                @"[In t:NonEmptyArrayOfItemIdsType Complex Type][ItemId] specifies the item identifier of an item to export from a mailbox.");
            #endregion

            #region Call UploadItems operation and set the CreateAction element to CreateNew to upload the items that exported in last step.
            ExportItemsResponseMessageType[] exportItemsResponseMessages = TestSuiteHelper.GetResponseMessages <ExportItemsResponseMessageType>(exportItemsResponse);

            // Initialize the upload items using the data of previous export items and set the item CreateAction to CreateNew.
            UploadItemsResponseMessageType[] uploadItemsResponse = this.UploadItems(exportItemsResponseMessages, this.OriginalFolderId, CreateActionType.CreateNew, true, true, false);
            #endregion

            #region Verify the UploadItems response related requirements when the CreateAction is CreateNew.
            // If the UploadItems response item's ID is not the same as the previous exported item's ID, then MS-OXWSBTRF_R228 can be captured.
            bool isNotSameItemId = false;
            for (int i = 0; i < uploadItemsResponse.Length; i++)
            {
                // Log the expected and actual value
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "The uploaded item's id: '{0}' should not be same with the exported item's id when the CreateAction is set to CreateNew: {1}.",
                    uploadItemsResponse[i].ItemId.Id,
                    exportItemsResponseMessages[i].ItemId.Id);
                if (exportItemsResponseMessages[i].ItemId.Id != uploadItemsResponse[i].ItemId.Id)
                {
                    isNotSameItemId = true;
                }
                else
                {
                    isNotSameItemId = false;
                    break;
                }
            }

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

            // Verify Requirement: MS-OXWSBTRF_R228.
            Site.CaptureRequirementIfIsTrue(
                isNotSameItemId,
                228,
                @"[In CreateActionType Simple Type][CreateNew]
                    The <ItemId> element that is returned in the UploadItemsResponseMessageType complex type, as specified in section 3.1.4.2.3.2, 
                    MUST contain the new item identifier.");

            // Call getItem to get the items that was uploaded
            ItemIdType[] itemIds = new ItemIdType[uploadItemsResponse.Length];
            for (int i = 0; i < uploadItemsResponse.Length; i++)
            {
                itemIds[i] = uploadItemsResponse[i].ItemId;
            }

            ItemType[] getItems = this.GetItems(itemIds);

            // Verify the array of items uploaded to a mailbox
            this.VerifyItemsUploadedToMailbox(getItems);

            // If the verification of the items uploaded to mailbox is successful, then this requirement can be captured.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSBTRF_R226");

            // Verify requirement MS-OXWSBTRF_R226
            Site.CaptureRequirement(
                226,
                @"[In CreateActionType Simple Type]The Value of CreateNew specifies that a new copy of the original item is uploaded to the mailbox.");

            // If the value of IsAssociated attribute in getItem response is same with the value in uploadItems request,
            // then requirement MS-OXWSBTRF_R222 can be captured.
            bool isSameIsAssociated = false;
            for (int i = 0; i < getItems.Length; i++)
            {
                // Log the expected and actual value
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "The value of IsAssociated attribute: {0} in getItem response should be: true",
                    getItems[i].IsAssociated);
                if (true == getItems[i].IsAssociated)
                {
                    isSameIsAssociated = true;
                }
                else
                {
                    isSameIsAssociated = false;
                    break;
                }
            }

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

            // Verify requirement MS-OXWSBTRF_R222
            Site.CaptureRequirementIfIsTrue(
                isSameIsAssociated,
                222,
                @"[In m:UploadItemType Complex Type]If it [IsAssociated] is present, it indicates that the item is a folder associated item.");
            #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
        }
예제 #4
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
        }
예제 #5
0
        /// <summary>
        /// Get the ExportItemsResponseMessageType response of ExportItems operation.
        /// </summary>
        /// <param name="configureSOAPHeader">A Boolean value specifies whether configuring the SOAP header before calling operations.</param>
        /// <returns>The array of ExportItemsResponseMessageType response.</returns>
        protected ExportItemsResponseMessageType[] ExportItems(bool configureSOAPHeader)
        {
            #region Prerequisite.
            // In the initialize step, three items in the specified sub folder have been created.
            // If that step executes successfully, the length of CreatedItemId list should be equal to the length of OriginalFolderId list.
            Site.Assert.AreEqual <int>(
                this.CreatedItemId.Count,
                this.OriginalFolderId.Count,
                string.Format(
                    "The exportedItemIds array should contain {0} item ids, actually, it contains {1}",
                    this.OriginalFolderId.Count,
                    this.CreatedItemId.Count));
            #endregion

            #region Call ExportItems operation to export the items from the server.
            // Initialize the export items' instances.
            ExportItemsType exportItems = new ExportItemsType();

            // Initialize three ItemIdType instances.
            exportItems.ItemIds = new ItemIdType[this.ItemCount];
            for (int i = 0; i < exportItems.ItemIds.Length; i++)
            {
                exportItems.ItemIds[i]    = new ItemIdType();
                exportItems.ItemIds[i].Id = this.CreatedItemId[i].Id;
            }

            // Initialize a ExportItemsResponseType instance.
            ExportItemsResponseType exportItemsResponse = this.BTRFAdapter.ExportItems(exportItems);

            // Check whether the operation is executed successfully.
            foreach (ExportItemsResponseMessageType exportResponse in exportItemsResponse.ResponseMessages.Items)
            {
                Site.Assert.AreEqual <ResponseClassType>(
                    ResponseClassType.Success,
                    exportResponse.ResponseClass,
                    string.Format(
                        "Export items should be successful! Expected response code: {0}, actual response code: {1}",
                        ResponseCodeType.NoError,
                        exportResponse.ResponseCode));
            }

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

            #region Verify the ExportItems response related requirements.
            // Verify the ExportItemsResponseType related requirements.
            this.VerifyExportItemsSuccessResponse(exportItemsResponse);
            #endregion

            #region Get the ExportItemsResponseMessageType items.
            ExportItemsResponseMessageType[] exportItemsResponseMessages =
                TestSuiteHelper.GetResponseMessages <ExportItemsResponseMessageType>(exportItemsResponse);
            return(exportItemsResponseMessages);

            #endregion
        }