/// <remarks/>
 public System.IAsyncResult BeginCreateFolder(CreateFolderType CreateFolder1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("CreateFolder", new object[] {
                 CreateFolder1}, callback, asyncState);
 }
        public void MSOXWSFOLD_S04_TC08_GetExtendedProperty()
        {
            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Set folder class to null.
            createFolderRequest.Folders[0].FolderClass = null;

            // Set folder extended property and its value.
            PathToExtendedFieldType publishInAddressBook = new PathToExtendedFieldType();

            // Set extended property Id and type.
            publishInAddressBook.PropertyTag  = "0x671E";
            publishInAddressBook.PropertyType = MapiPropertyTypeType.Boolean;

            ExtendedPropertyType pubAddressbook = new ExtendedPropertyType();
            pubAddressbook.ExtendedFieldURI = publishInAddressBook;

            // Set extended property value.
            pubAddressbook.Item = "1";

            ExtendedPropertyType[] extendedProperties = new ExtendedPropertyType[1];
            extendedProperties[0] = pubAddressbook;

            createFolderRequest.Folders[0].ExtendedProperty = extendedProperties;

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R7801
            // Folder created successfully with extended property this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                createFolderResponse.ResponseMessages.Items[0].ResponseCode,
                7801,
                @"[In t:BaseFolderType Complex Type]This element [ExtendedProperty] is present, server responses NO_ERROR.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R980302
            //  Folder created successfully without permission set so this requirement can be covered.
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                createFolderResponse.ResponseMessages.Items[0].ResponseCode,
                980302,
                @"[In t:FolderType Complex Type]This element [PermissionSet] is not present, server responses NO_ERROR.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R589202
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                createFolderResponse.ResponseMessages.Items[0].ResponseCode,
                589202,
                @"[In t:BaseFolderType Complex Type]This element [FolderClass] is not present, server responses NO_ERROR.");

            #region Get the new created folder

            // GetFolder request.
            GetFolderType getNewFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);
            getNewFolderRequest.FolderShape.AdditionalProperties    = new BasePathToElementType[1];
            getNewFolderRequest.FolderShape.AdditionalProperties[0] = publishInAddressBook;

            // Get the new created folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getNewFolderRequest);

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

            FolderInfoResponseMessageType allFolders = (FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0];
            FolderType folderInfo = (FolderType)allFolders.Folders[0];

            #endregion

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

            // Folder ids is set in request and response is returned from server so this requirement can be captured.
            this.Site.CaptureRequirement(
                423,
                @"[In m:GetFolderType Complex Type]FolderIds is an array of one or more folder identifiers.");

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

            // Folder id that contains id and change key value is set in request and response is returned from server so this requirement can be captured.
            this.Site.CaptureRequirement(
                426,
                @"[In t:NonEmptyArrayOfBaseFolderIdsType Complex Type]FolderId specifies the folder identifier and change key. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R77
            // Extended property value is returned from server, and schema is verified in adapter so this requirement can be covered.
            this.Site.CaptureRequirementIfIsNotNull(
                folderInfo.ExtendedProperty,
                77,
                @"[In t:BaseFolderType Complex Type]The type of element ExtendedProperty is t:ExtendedPropertyType ([MS-OXWSXPROP] section 2.1.5).");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R7701
            // In create operation this property value is set to 1 and type to Boolean this means the value is "true" in string type.
            this.Site.CaptureRequirementIfAreEqual <string>(
                "true",
                ((ExtendedPropertyType)folderInfo.ExtendedProperty.GetValue(0)).Item.ToString(),
                7701,
                @"[In t:BaseFolderType Complex Type]ExtendedProperty specifies the set of extended properties on a folder.");
        }
示例#3
0
        public void MSOXWSFOLD_S02_TC03_CopyPublicFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(55501, this.Site), "Exchange 2007 and Exchange 2010 support the CopyFolder operation if either the source folder or the destination folder is a public folder");

            #region Create a new public folder in the public folder root

            // CreateFolder request.
            CreateFolderType createPublicFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.publicfoldersroot.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new public folder.
            CreateFolderResponseType createPublicFolderResponse = this.FOLDAdapter.CreateFolder(createPublicFolderRequest);

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

            // Save the new created public folder's folder id.
            FolderIdType newPublicFolderId = ((FolderInfoResponseMessageType)createPublicFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newPublicFolderId);

            #endregion

            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Copy the public folder to the folder created in inbox

            // CopyFolder request.
            CopyFolderType copyPublicFolderRequest = this.GetCopyFolderRequest(newFolderId.Id, newPublicFolderId);

            // Copy the public folder.
            CopyFolderResponseType copyPublicFolderResponse = this.FOLDAdapter.CopyFolder(copyPublicFolderRequest);

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

            // Variable to save the folder.
            FolderIdType copiedPublicFolderId = ((FolderInfoResponseMessageType)copyPublicFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the copied folder's folder id.
            this.NewCreatedFolderIds.Add(copiedPublicFolderId);

            #endregion

            #region Get the new copied public folder that in inbox

            // GetFolder request.
            GetFolderType getNewCopiedPulicFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, copiedPublicFolderId);

            // Get the new copied public folder.
            GetFolderResponseType getNewCopiedPublicFolderResponse = this.FOLDAdapter.GetFolder(getNewCopiedPulicFolderRequest);

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

            #endregion

            #region Copy the folder in inbox to the public folder created

            // CopyFolder request.
            CopyFolderType copyFolderRequest = this.GetCopyFolderRequest(newPublicFolderId.Id, newFolderId);

            // Copy the public folder.
            CopyFolderResponseType copyFolderResponse = this.FOLDAdapter.CopyFolder(copyFolderRequest);

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

            // Variable to save the folder.
            FolderIdType copiedFolderId = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the copied folder's folder id.
            this.NewCreatedFolderIds.Add(copiedFolderId);

            #endregion

            #region Get the new copied folder that in root public folder

            // GetFolder request.
            GetFolderType getNewCopiedFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, copiedFolderId);

            // Get the new copied folder.
            GetFolderResponseType getNewCopiedFolderResponse = this.FOLDAdapter.GetFolder(getNewCopiedFolderRequest);

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

            #endregion

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

            // Folder can be copied successfully either when the source folder or destination folder is public folder ,so this requirement can be captured.
            this.Site.CaptureRequirement(
                55501,
                @"[In Appendix C: Product Behavior] Implementation does support the CopyFolder operation if either the source folder or the destination folder is a public folder.(Exchange Server 2007 and Exchange Server 2010 follow this behavior.)");
        }
        public void MSOXWSFOLD_S05_TC05_SoftEmptyFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");
            Site.Assume.IsTrue(Common.IsRequirementEnabled(4000, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not include enumeration value recoverableitemsdeletions");

            #region Create a new folder in the inbox folder

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Create an item

            string itemName = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            #endregion

            #region Get the new created folder

            // GetFolder request.
            GetFolderType getNewFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the new created folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getNewFolderRequest);

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

            #endregion

            #region Empty the created folder

            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(newFolderId, DisposalType.SoftDelete, true);
            Common.CheckOperationSuccess(emptyFolderResponse, 1, this.Site);

            #endregion

            #region Find the item
            ItemIdType findItemID = this.FindItem(DistinguishedFolderIdNameType.recoverableitemsdeletions.ToString(), itemName);

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

            this.Site.CaptureRequirementIfIsNotNull(
                findItemID,
                37803,
                @"[In m:EmptyFolderType Complex Type ]DeleteType which value is SoftDelete specifies that an item or folder is moved to the dumpster if the dumpster is enabled.");

            DeleteItemType deleteItemRequest = new DeleteItemType();
            deleteItemRequest.ItemIds = new BaseItemIdType[] { findItemID };
            DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest);
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);
            #endregion
        }
        public void MSOXWSFOLD_S03_TC01_FolderPropertiesAfterMoved()
        {
            #region Create two nested folders with an item in the high-level one into the "drafts" folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.drafts.ToString(), new string[] { "ForMoveFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Create a message into this folder
            string     itemName = Common.GenerateResourceName(this.Site, "Test Mail");
            ItemIdType itemId   = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName);
            this.NewCreatedItemIds.Add(itemId);

            // Create sub folder request.
            CreateFolderType createSubFolderRequest = this.GetCreateFolderRequest(newFolderId.Id, new string[] { "SubFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createNewFolderResponse = this.FOLDAdapter.CreateFolder(createSubFolderRequest);

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

            FolderIdType subFolderId = ((FolderInfoResponseMessageType)createNewFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(subFolderId);

            #endregion

            #region Move the new created folder to the inbox folder

            // MoveFolder request.
            MoveFolderType moveFolderRequest = new MoveFolderType();

            // Set the request's folderId field.
            moveFolderRequest.FolderIds    = new BaseFolderIdType[1];
            moveFolderRequest.FolderIds[0] = newFolderId;

            // Set the request's destFolderId field.
            DistinguishedFolderIdType toFolderId = new DistinguishedFolderIdType();
            toFolderId.Id = DistinguishedFolderIdNameType.inbox;
            moveFolderRequest.ToFolderId      = new TargetFolderIdType();
            moveFolderRequest.ToFolderId.Item = toFolderId;

            // Move the specified folder.
            MoveFolderResponseType moveFolderResponse = this.FOLDAdapter.MoveFolder(moveFolderRequest);

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

            FolderIdType movedFolderId = ((FolderInfoResponseMessageType)moveFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(movedFolderId);
            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R4314
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                moveFolderResponse.ResponseMessages.Items[0].ResponseCode,
                4314,
                @"[In MoveFolder Operation]A successful MoveFolder operation request returns a MoveFolderResponse element with the ResponseCode element of the MoveFolderResponse element set to ""NoError"".");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R43144
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                moveFolderResponse.ResponseMessages.Items[0].ResponseClass,
                43144,
                @"[In MoveFolder Operation]A successful MoveFolder operation request returns a MoveFolderResponse element with the ResponseClass attribute of the MoveFolderResponseMessage element set to ""Success"".");

            #region Get the inbox folder's folder id

            DistinguishedFolderIdType folder = new DistinguishedFolderIdType();
            folder.Id = DistinguishedFolderIdNameType.inbox;

            // GetFolder request.
            GetFolderType getInboxFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folder);

            // Get the Inbox folder.
            GetFolderResponseType getInboxFolderResponse = this.FOLDAdapter.GetFolder(getInboxFolderRequest);

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

            // Variable to save folder.
            FolderInfoResponseMessageType inboxFolder = (FolderInfoResponseMessageType)getInboxFolderResponse.ResponseMessages.Items[0];
            BaseFolderType inboxFolderInfo            = (BaseFolderType)inboxFolder.Folders[0];

            // Save the inbox's folder id.
            FolderIdType inboxFolderId = inboxFolderInfo.FolderId;

            #endregion

            #region Get the new created folder after moved to inbox folder

            // GetFolder request.
            GetFolderType getSubFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, movedFolderId);

            // Get the specified folder.
            GetFolderResponseType getSubFolderResponse = this.FOLDAdapter.GetFolder(getSubFolderRequest);

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

            FolderInfoResponseMessageType allFolders = (FolderInfoResponseMessageType)getSubFolderResponse.ResponseMessages.Items[0];
            BaseFolderType folderInfo = (BaseFolderType)allFolders.Folders[0];

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R595
            // Since one message in the folder before move, if TotalCount for the folder is 1 after move, this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual <int>(
                1,
                folderInfo.TotalCount,
                595,
                @"[In MoveFolder Operation]The contents of the folder move with the folder.");

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

            // The moved folder can be gotten successfully, so the specified folder was moved.
            this.Site.CaptureRequirement(
                461,
                @"[In m:MoveFolderType Complex Type]The MoveFolderType complex type specifies a request message to move folders in a mailbox.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R429
            this.Site.CaptureRequirementIfAreEqual <string>(
                inboxFolderId.Id,
                folderInfo.ParentFolderId.Id,
                429,
                @"[In MoveFolder Operation]The MoveFolder operation moves folders from a specified parent folder and puts them in another parent folder.");

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

            // Verify MS-OXWSFOLD_R594.
            // Verify if the values of FolderClass and DisplayName property are changed after the folder being moved.
            bool isVerifyR594 = folderInfo.FolderClass == "IPF.MyCustomFolderClass" &&
                                folderInfo.DisplayName == createFolderRequest.Folders[0].DisplayName;

            Site.Log.Add(
                LogEntryKind.Debug,
                "FolderClass expected to be \"IPF.MyCustomFolderClass\" and actual is {0};\n" +
                "DisplayName expected to be {1} and actual is {2};\n ",
                folderInfo.FolderClass,
                createFolderRequest.Folders[0].DisplayName,
                folderInfo.DisplayName);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR594,
                594,
                @"[In MoveFolder Operation]The properties FolderClass and DisplayName of the folder move with the folder.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R7501
            // Only one child folder was created in the folder.
            this.Site.CaptureRequirementIfAreEqual <int>(
                1,
                folderInfo.ChildFolderCount,
                7501,
                @"[In t:BaseFolderType Complex Type]ChildFolderCount specifies the total number of child folders in a folder.");

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

            // Child folder count is returned from server so this requirement can be captured.
            this.Site.CaptureRequirement(
                5912,
                @"[In t:BaseFolderType Complex Type]This property[ChildFolderCount] is returned in a response.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R75
            this.Site.CaptureRequirementIfIsNotNull(
                folderInfo.ChildFolderCount,
                75,
                @"[In t:BaseFolderType Complex Type]The type of element ChildFolderCount is xs:int.");

            #region Get subfolder in the moved folder

            // GetFolder request.
            GetFolderType getSubFolderAfterMovedRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, subFolderId);

            // Get the specified folder.
            GetFolderResponseType getFolderAfterMovedResponse = this.FOLDAdapter.GetFolder(getSubFolderAfterMovedRequest);

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

            allFolders = (FolderInfoResponseMessageType)getFolderAfterMovedResponse.ResponseMessages.Items[0];
            folderInfo = (BaseFolderType)allFolders.Folders[0];

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R596
            this.Site.CaptureRequirementIfAreEqual <string>(
                movedFolderId.ToString(),
                folderInfo.ParentFolderId.ToString(),
                596,
                @"[In MoveFolder Operation]The subfolders of the folder move with the folder.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R68
            // Parent folder id is returned from server, and schema is verified in adapter so this requirement can be covered.
            this.Site.CaptureRequirementIfIsNotNull(
                folderInfo.ParentFolderId,
                68,
                @"[In t:BaseFolderType Complex Type]The type of element ParentFolderId is t:FolderIdType.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R6801
            this.Site.CaptureRequirementIfAreEqual <string>(
                NewCreatedFolderIds[0].ToString(),
                folderInfo.ParentFolderId.ToString(),
                6801,
                @"[In t:BaseFolderType Complex Type]ParentFolderId specifies the folder identifier and change key for the parent folder.");
        }
        /// <summary>
        /// Log on to a mailbox with a specified user account and create a search folder.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">Password of the user.</param>
        /// <param name="userDomain">Domain of the user.</param>
        /// <param name="searchFolderName">Name of the search folder.</param>
        /// <param name="searchText">Search text of the search folder.</param>
        /// <returns>If the search folder is created successfully, return true; otherwise, return false.</returns>
        public bool CreateSearchFolder(string userName, string userPassword, string userDomain, string searchFolderName, string searchText)
        {
            // Log on mailbox with specified user account(userName, userPassword, userDomain).
            bool isLoged = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site);

            Site.Assert.IsTrue(
                isLoged,
                string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain));

            // Create the request.
            CreateFolderType createFolder = new CreateFolderType();

            SearchFolderType[] folderArray  = new SearchFolderType[1];
            SearchFolderType   searchFolder = new SearchFolderType();

            // Use the following search filter to get all mail in the Inbox with the word searchText in the subject line.
            searchFolder.SearchParameters                    = new SearchParametersType();
            searchFolder.SearchParameters.Traversal          = SearchFolderTraversalType.Deep;
            searchFolder.SearchParameters.TraversalSpecified = true;
            searchFolder.SearchParameters.BaseFolderIds      = new DistinguishedFolderIdType[4];

            // Create a distinguished folder Identified of the inbox folder.
            DistinguishedFolderIdType inboxFolder = new DistinguishedFolderIdType();

            inboxFolder.Id = new DistinguishedFolderIdNameType();
            inboxFolder.Id = DistinguishedFolderIdNameType.inbox;
            searchFolder.SearchParameters.BaseFolderIds[0] = inboxFolder;
            DistinguishedFolderIdType contactType = new DistinguishedFolderIdType();

            contactType.Id = new DistinguishedFolderIdNameType();
            contactType.Id = DistinguishedFolderIdNameType.contacts;
            searchFolder.SearchParameters.BaseFolderIds[1] = contactType;
            DistinguishedFolderIdType calendarType = new DistinguishedFolderIdType();

            calendarType.Id = new DistinguishedFolderIdNameType();
            calendarType.Id = DistinguishedFolderIdNameType.calendar;
            searchFolder.SearchParameters.BaseFolderIds[2] = calendarType;
            DistinguishedFolderIdType taskType = new DistinguishedFolderIdType();

            taskType.Id = new DistinguishedFolderIdNameType();
            taskType.Id = DistinguishedFolderIdNameType.calendar;
            searchFolder.SearchParameters.BaseFolderIds[3] = taskType;

            // Use the following search filter.
            searchFolder.SearchParameters.Restriction = new RestrictionType();
            PathToUnindexedFieldType path = new PathToUnindexedFieldType();

            path.FieldURI = UnindexedFieldURIType.itemSubject;
            RestrictionType        restriction        = new RestrictionType();
            FieldURIOrConstantType fieldURIORConstant = new FieldURIOrConstantType();

            fieldURIORConstant.Item = new ConstantValueType();
            (fieldURIORConstant.Item as ConstantValueType).Value = searchText;
            ExistsType isEqual = new ExistsType();

            isEqual.Item     = path;
            restriction.Item = isEqual;
            searchFolder.SearchParameters.Restriction = restriction;

            // Give the search folder a unique name.
            searchFolder.DisplayName = searchFolderName;
            folderArray[0]           = searchFolder;

            // Create the search folder under the default Search Folder.
            TargetFolderIdType        targetFolder  = new TargetFolderIdType();
            DistinguishedFolderIdType searchFolders = new DistinguishedFolderIdType();

            searchFolders.Id            = DistinguishedFolderIdNameType.searchfolders;
            targetFolder.Item           = searchFolders;
            createFolder.ParentFolderId = targetFolder;
            createFolder.Folders        = folderArray;
            bool isSearchFolderCreated = false;

            // Invoke CreateFolder operation and get the response.
            CreateFolderResponseType response = this.exchangeServiceBinding.CreateFolder(createFolder);

            if (response != null && ResponseClassType.Success == response.ResponseMessages.Items[0].ResponseClass)
            {
                // If the search folder is created successfully, return true; otherwise, return false.
                isSearchFolderCreated = true;

                searchFolder.FolderId = ((FolderInfoResponseMessageType)response.ResponseMessages.Items[0]).Folders[0].FolderId;
                AdapterHelper.CreatedFolders.Add(searchFolder);
            }

            return(isSearchFolderCreated);
        }
        public void MSOXWSFOLD_S06_TC04_UpdateFolderWithDeleteFolderFieldType()
        {
            #region Create a new folder in the inbox folder

            // Configure permission set.
            PermissionSetType permissionSet = new PermissionSetType();
            permissionSet.Permissions    = new PermissionType[1];
            permissionSet.Permissions[0] = new PermissionType();
            permissionSet.Permissions[0].CanCreateSubFolders          = true;
            permissionSet.Permissions[0].CanCreateSubFoldersSpecified = true;
            permissionSet.Permissions[0].IsFolderOwner          = true;
            permissionSet.Permissions[0].IsFolderOwnerSpecified = true;
            permissionSet.Permissions[0].PermissionLevel        = new PermissionLevelType();
            permissionSet.Permissions[0].PermissionLevel        = PermissionLevelType.Custom;
            permissionSet.Permissions[0].UserId = new UserIdType();
            permissionSet.Permissions[0].UserId.PrimarySmtpAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, new PermissionSetType[] { permissionSet });

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Update Folder Operation.

            // UpdateFolder request to delete folder permission value.
            UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest("Folder", "DeleteFolderField", newFolderId);

            // Update the specific folder's properties.
            UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest);

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

            #endregion

            #region Switch user

            this.SwitchUser(Common.GetConfigurationPropertyValue("User2Name", this.Site), Common.GetConfigurationPropertyValue("User2Password", this.Site), Common.GetConfigurationPropertyValue("Domain", this.Site));

            #endregion

            #region Create a subfolder under the folder created in step 1 with User2's credential

            // CreateFolder request.
            CreateFolderType createFolderInSharedMailboxRequest = this.GetCreateFolderRequest(newFolderId.Id, new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderInSharedMailboxResponse = this.FOLDAdapter.CreateFolder(createFolderInSharedMailboxRequest);

            // Check the length.
            Site.Assert.AreEqual <int>(
                1,
                createFolderInSharedMailboxResponse.ResponseMessages.Items.GetLength(0),
                "Expected Item Count: {0}, Actual Item Count: {1}",
                1,
                createFolderInSharedMailboxResponse.ResponseMessages.Items.GetLength(0));

            // Permission have been deleted so create operation should be failed.
            bool isPermissionDeleted = createFolderInSharedMailboxResponse.ResponseMessages.Items[0].ResponseClass.Equals(ResponseClassType.Error);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R583
            // One permission set which set in CreateFolder is deleted when calling UpdateFolder.
            this.Site.CaptureRequirementIfIsTrue(
                isPermissionDeleted,
                583,
                @"[In t:DeleteFolderFieldType Complex Type]The DeleteFolderFieldType complex type represents an UpdateFolder operation to delete a property from a folder.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R5261
            this.Site.CaptureRequirementIfIsTrue(
                isPermissionDeleted,
                5261,
                @"[In t:NonEmptyArrayOfFolderChangeDescriptionsType Complex Type]DeleteFolderField represents an UpdateFolder operation to delete a property from a folder.");
        }
        /// <summary>
        /// Create a sub folder in the specified parent folder.
        /// </summary>
        /// <param name="parentFolderType">Type of the parent folder.</param>
        /// <param name="subFolderName">Name of the folder which should be created.</param>
        /// <returns>ID of the new created sub folder.</returns>
        protected string CreateSubFolder(DistinguishedFolderIdNameType parentFolderType, string subFolderName)
        {
            // Variable to specified the created sub folder ID and the folder class name.
            string subFolderId     = null;
            string folderClassName = null;

            // Set the folder's class name according to the type of parent folder.
            switch (parentFolderType)
            {
            case DistinguishedFolderIdNameType.contacts:
                folderClassName = "IPF.Contact";
                break;

            case DistinguishedFolderIdNameType.calendar:
                folderClassName = "IPF.Appointment";
                break;

            case DistinguishedFolderIdNameType.tasks:
                folderClassName = "IPF.Task";
                break;

            case DistinguishedFolderIdNameType.inbox:
                folderClassName = "IPF.Note";
                break;

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

            // Initialize the create folder request.
            CreateFolderType createFolderRequest = new CreateFolderType();
            FolderType       folderProperties    = new FolderType();

            // Set parent folder id.
            createFolderRequest.ParentFolderId = new TargetFolderIdType();
            DistinguishedFolderIdType parentFolder = new DistinguishedFolderIdType();

            parentFolder.Id = parentFolderType;
            createFolderRequest.ParentFolderId.Item = parentFolder;

            // Set Display Name and Folder Class for the folder to be created.
            folderProperties.DisplayName = subFolderName;
            folderProperties.FolderClass = folderClassName;

            // Set permission.
            folderProperties.PermissionSet                = new PermissionSetType();
            folderProperties.PermissionSet.Permissions    = new PermissionType[1];
            folderProperties.PermissionSet.Permissions[0] = new PermissionType();
            folderProperties.PermissionSet.Permissions[0].CanCreateItems      = true;
            folderProperties.PermissionSet.Permissions[0].CanCreateSubFolders = true;
            folderProperties.PermissionSet.Permissions[0].PermissionLevel     = new PermissionLevelType();
            folderProperties.PermissionSet.Permissions[0].PermissionLevel     = PermissionLevelType.Editor;
            folderProperties.PermissionSet.Permissions[0].UserId = new UserIdType();

            string primaryUserName = Common.GetConfigurationPropertyValue("UserName", this.Site);
            string primaryDomain   = Common.GetConfigurationPropertyValue("Domain", this.Site);

            folderProperties.PermissionSet.Permissions[0].UserId.PrimarySmtpAddress = primaryUserName + "@" + primaryDomain;

            createFolderRequest.Folders    = new BaseFolderType[1];
            createFolderRequest.Folders[0] = folderProperties;

            // Invoke CreateFolder operation and get the response.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            if (createFolderResponse != null && createFolderResponse.ResponseMessages.Items[0].ResponseClass.ToString() == ResponseClassType.Success.ToString())
            {
                FolderIdType folderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
                subFolderId = folderId.Id;
                FolderType created = new FolderType()
                {
                    DisplayName = folderProperties.DisplayName, FolderClass = folderClassName, FolderId = folderId, ParentFolderId = new FolderIdType()
                    {
                        Id = parentFolder.Id.ToString()
                    }
                };
                this.CreatedFolders.Add(created);
            }

            return(subFolderId);
        }
        public void MSOXWSFOLD_S05_TC02_EmptyFolderWithoutDeletingSubFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");

            #region Create a new item and a new folder with an item in the Inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "ToBeDeleteFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(newFolderId);

            string itemName1 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemInFolder = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName1);
            Site.Assert.IsNotNull(itemInFolder, "Item should be created successfully!");
            string itemName2 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in inbox.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), DistinguishedFolderIdNameType.inbox.ToString(), itemName2);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            // Variable to indicate whether the item2 is created properly.
            bool isItem2Created = this.FindItem(DistinguishedFolderIdNameType.inbox.ToString(), itemName2) != null;

            Site.Assert.IsTrue(isItem2Created, "The item should be created successfully in the specific folder.");

            #endregion

            #region Empty the inbox folder.

            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;

            // Empty the specific folder
            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(folderId, DisposalType.HardDelete, false);

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

            #endregion

            #region Get the folder in inbox folder to verify whether it has been deleted

            // GetFolder request.
            GetFolderType getFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the specific folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getFolderRequest);

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

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R381.
            Site.CaptureRequirementIfAreNotEqual <ResponseCodeType>(
                ResponseCodeType.ErrorItemNotFound,
                getFolderResponse.ResponseMessages.Items[0].ResponseCode,
                381,
                @"[In m:EmptyFolderType Complex Type][if the subfolders are not to be deleted], it is set to ""false"". ");
        }
示例#10
0
        public void MSOXWSFOLD_S08_TC01_AllOperationsWithAllOptionalElements()
        {
            #region Configure SOAP header

            this.ConfigureSOAPHeader();

            #endregion

            #region Create new folders in the inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(
                DistinguishedFolderIdNameType.inbox.ToString(),
                new string[] { "Custom Folder1", "Custom Folder2", "Custom Folder3", "Custom Folder4" },
                new string[] { "IPF.MyCustomFolderClass", "IPF.Appointment", "IPF.Contact", "IPF.Task" },
                null);

            // Set ExtendedProperty defined in BaseFolderType.
            PathToExtendedFieldType publishInAddressBook = new PathToExtendedFieldType();

            // A hexadecimal tag of the extended property.
            publishInAddressBook.PropertyTag  = "0x671E";
            publishInAddressBook.PropertyType = MapiPropertyTypeType.Boolean;
            ExtendedPropertyType pubAddressbook = new ExtendedPropertyType();
            pubAddressbook.ExtendedFieldURI = publishInAddressBook;
            pubAddressbook.Item             = "1";
            ExtendedPropertyType[] extendedProperties = new ExtendedPropertyType[1];
            extendedProperties[0] = pubAddressbook;

            createFolderRequest.Folders[0].ExtendedProperty = extendedProperties;
            createFolderRequest.Folders[1].ExtendedProperty = extendedProperties;
            createFolderRequest.Folders[2].ExtendedProperty = extendedProperties;
            createFolderRequest.Folders[3].ExtendedProperty = extendedProperties;

            // Define a permissionSet with all optional elements
            PermissionSetType permissionSet = new PermissionSetType();
            permissionSet.Permissions                                 = new PermissionType[1];
            permissionSet.Permissions[0]                              = new PermissionType();
            permissionSet.Permissions[0].ReadItems                    = new PermissionReadAccessType();
            permissionSet.Permissions[0].ReadItems                    = PermissionReadAccessType.FullDetails;
            permissionSet.Permissions[0].ReadItemsSpecified           = true;
            permissionSet.Permissions[0].CanCreateItems               = true;
            permissionSet.Permissions[0].CanCreateItemsSpecified      = true;
            permissionSet.Permissions[0].CanCreateSubFolders          = true;
            permissionSet.Permissions[0].CanCreateSubFoldersSpecified = true;
            permissionSet.Permissions[0].IsFolderVisible              = true;
            permissionSet.Permissions[0].IsFolderVisibleSpecified     = true;
            permissionSet.Permissions[0].IsFolderContact              = true;
            permissionSet.Permissions[0].IsFolderContactSpecified     = true;
            permissionSet.Permissions[0].IsFolderOwner                = true;
            permissionSet.Permissions[0].IsFolderOwnerSpecified       = true;
            permissionSet.Permissions[0].IsFolderContact              = true;
            permissionSet.Permissions[0].IsFolderContactSpecified     = true;
            permissionSet.Permissions[0].EditItems                    = new PermissionActionType();
            permissionSet.Permissions[0].EditItems                    = PermissionActionType.All;
            permissionSet.Permissions[0].EditItemsSpecified           = true;
            permissionSet.Permissions[0].DeleteItems                  = new PermissionActionType();
            permissionSet.Permissions[0].DeleteItems                  = PermissionActionType.All;
            permissionSet.Permissions[0].DeleteItemsSpecified         = true;
            permissionSet.Permissions[0].PermissionLevel              = new PermissionLevelType();
            permissionSet.Permissions[0].PermissionLevel              = PermissionLevelType.Custom;
            permissionSet.Permissions[0].UserId                       = new UserIdType();
            permissionSet.Permissions[0].UserId.PrimarySmtpAddress    = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);

            // Set PermissionSet for FolderType folder.
            ((FolderType)createFolderRequest.Folders[0]).PermissionSet = permissionSet;

            // Set PermissionSet for ContactsType folder.
            ((ContactsFolderType)createFolderRequest.Folders[2]).PermissionSet = permissionSet;

            // Set PermissionSet for TasksFolderType folder.
            ((TasksFolderType)createFolderRequest.Folders[3]).PermissionSet = permissionSet;

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 4, this.Site);

            // Folder ids.
            FolderIdType[] folderIds = new FolderIdType[createFolderResponse.ResponseMessages.Items.Length];

            for (int index = 0; index < createFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, createFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be created successfully!");

                // Save folder ids.
                folderIds[index] = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[index]).Folders[0].FolderId;

                // Save the new created folder's folder id.
                this.NewCreatedFolderIds.Add(folderIds[index]);
            }

            #endregion

            #region Create a managedfolder

            CreateManagedFolderRequestType createManagedFolderRequest = this.GetCreateManagedFolderRequest(Common.GetConfigurationPropertyValue("ManagedFolderName1", this.Site));

            // Add an email address into request.
            EmailAddressType mailBox = new EmailAddressType()
            {
                EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site)
            };

            createManagedFolderRequest.Mailbox = mailBox;

            // Create the specified managed folder.
            CreateManagedFolderResponseType createManagedFolderResponse = this.FOLDAdapter.CreateManagedFolder(createManagedFolderRequest);

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

            // Save the new created managed folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createManagedFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Get the new created folders

            // GetFolder request.
            GetFolderType getCreatedFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folderIds);

            // Get the new created folder.
            GetFolderResponseType getCreatedFolderResponse = this.FOLDAdapter.GetFolder(getCreatedFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getCreatedFolderResponse, 4, this.Site);

            for (int index = 0; index < getCreatedFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, getCreatedFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder information should be returned!");
            }

            #endregion

            #region Update the new created folders

            // UpdateFolder request.
            UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest(
                new string[] { "Folder", "CalendarFolder", "ContactsFolder", "TasksFolder" },
                new string[] { "SetFolderField", "SetFolderField", "SetFolderField", "SetFolderField" },
                folderIds);

            // Update the folders' properties.
            UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(updateFolderResponse, 4, this.Site);

            for (int index = 0; index < updateFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, updateFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");
            }

            #endregion

            #region Copy the updated folders to "drafts" folder

            // Copy the folders into "drafts" folder
            CopyFolderType copyFolderRequest = this.GetCopyFolderRequest(DistinguishedFolderIdNameType.drafts.ToString(), folderIds);

            // Copy the folders.
            CopyFolderResponseType copyFolderResponse = this.FOLDAdapter.CopyFolder(copyFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(copyFolderResponse, 4, this.Site);

            // Copied Folders' id.
            FolderIdType[] copiedFolderIds = new FolderIdType[copyFolderResponse.ResponseMessages.Items.Length];

            for (int index = 0; index < copyFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, copyFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");

                // Variable to save the folders.
                copiedFolderIds[index] = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[index]).Folders[0].FolderId;

                // Save the copied folders' folder id.
                this.NewCreatedFolderIds.Add(copiedFolderIds[index]);
            }

            #endregion

            #region Move the updated folders to "deleteditems" folder

            // MoveFolder request.
            MoveFolderType moveFolderRequest = new MoveFolderType();

            // Set the request's folderId field.
            moveFolderRequest.FolderIds = folderIds;

            // Set the request's destFolderId field.
            DistinguishedFolderIdType toFolderId = new DistinguishedFolderIdType();
            toFolderId.Id = DistinguishedFolderIdNameType.deleteditems;
            moveFolderRequest.ToFolderId      = new TargetFolderIdType();
            moveFolderRequest.ToFolderId.Item = toFolderId;

            // Move the specified folders.
            MoveFolderResponseType moveFolderResponse = this.FOLDAdapter.MoveFolder(moveFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(moveFolderResponse, 4, this.Site);

            for (int index = 0; index < moveFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, moveFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");
            }
            #endregion

            #region Delete all folders

            // All folder ids.
            FolderIdType[] allFolderIds = new FolderIdType[folderIds.Length + copiedFolderIds.Length];

            for (int index = 0; index < allFolderIds.Length / 2; index++)
            {
                allFolderIds[index] = folderIds[index];
                allFolderIds[index + folderIds.Length] = copiedFolderIds[index];
            }

            // DeleteFolder request.
            DeleteFolderType deleteFolderRequest = this.GetDeleteFolderRequest(DisposalType.HardDelete, allFolderIds);

            // Delete the specified folder.
            DeleteFolderResponseType deleteFolderResponse = this.FOLDAdapter.DeleteFolder(deleteFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(deleteFolderResponse, 8, this.Site);

            for (int index = 0; index < deleteFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, deleteFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");
            }

            #endregion
        }
示例#11
0
    static void CreateFolder(ExchangeServiceBinding esb, FolderIdType fiFolderID, String fnFldName)
    {
        // Create the request
        FolderType folder = new FolderType();
        folder.DisplayName = fnFldName;

        TargetFolderIdType targetID = new TargetFolderIdType();
        targetID.Item = fiFolderID;

        CreateFolderType createFolder = new CreateFolderType();
        createFolder.Folders = new FolderType[] { folder };
        createFolder.ParentFolderId = targetID;

        try
        {
            // Send the request and get the response
            CreateFolderResponseType response = esb.CreateFolder(createFolder);

            // Get the response messages
            ResponseMessageType[] rmta = response.ResponseMessages.Items;

        }
        catch (Exception e)
        {
            string problem = e.Message;
        }
    }
示例#12
0
        public void MSOXWSFOLD_S08_TC02_AllOperationsWithoutAllOptionalElements()
        {
            #region Create new folders in the inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(
                DistinguishedFolderIdNameType.inbox.ToString(),
                new string[] { "Custom Folder1", "Custom Folder2", "Custom Folder3", "Custom Folder4" },
                new string[] { "IPF.MyCustomFolderClass", "IPF.Appointment", "IPF.Contact", "IPF.Task" },
                null);

            // Remove FolderClass for FolderType folder.
            createFolderRequest.Folders[0].FolderClass = null;

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 4, this.Site);

            // Folder ids.
            FolderIdType[] folderIds = new FolderIdType[createFolderResponse.ResponseMessages.Items.Length];

            for (int index = 0; index < createFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, createFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be created successfully!");

                // Save folder ids.
                folderIds[index] = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[index]).Folders[0].FolderId;

                // Save the new created folder's folder id.
                this.NewCreatedFolderIds.Add(folderIds[index]);
            }

            #endregion

            #region Create a managedfolder

            CreateManagedFolderRequestType createManagedFolderRequest = this.GetCreateManagedFolderRequest(Common.GetConfigurationPropertyValue("ManagedFolderName1", this.Site));

            // Create the specified managed folder.
            CreateManagedFolderResponseType createManagedFolderResponse = this.FOLDAdapter.CreateManagedFolder(createManagedFolderRequest);

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

            // Save the new created managed folder's folder id.
            FolderIdType newManagedFolderId = ((FolderInfoResponseMessageType)createManagedFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newManagedFolderId);

            #endregion

            #region Get the new created folders

            // GetFolder request.
            GetFolderType getCreatedFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folderIds);

            // Get the new created folder.
            GetFolderResponseType getCreatedFolderResponse = this.FOLDAdapter.GetFolder(getCreatedFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getCreatedFolderResponse, 4, this.Site);

            for (int index = 0; index < getCreatedFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, getCreatedFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder information should be returned!");
            }

            #endregion

            #region Update the new created folders

            // UpdateFolder request.
            UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest(
                new string[] { "Folder", "CalendarFolder", "ContactsFolder", "TasksFolder" },
                new string[] { "SetFolderField", "SetFolderField", "SetFolderField", "SetFolderField" },
                folderIds);

            // Update the folders' properties.
            UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(updateFolderResponse, 4, this.Site);

            for (int index = 0; index < updateFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, updateFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");
            }

            #endregion

            #region Copy the updated folders to "drafts" folder

            // Copy the folders into "drafts" folder
            CopyFolderType copyFolderRequest = this.GetCopyFolderRequest(DistinguishedFolderIdNameType.drafts.ToString(), folderIds);

            // Copy the folders.
            CopyFolderResponseType copyFolderResponse = this.FOLDAdapter.CopyFolder(copyFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(copyFolderResponse, 4, this.Site);

            // Copied folders' id.
            FolderIdType[] copiedFolderIds = new FolderIdType[copyFolderResponse.ResponseMessages.Items.Length];

            for (int index = 0; index < copyFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, copyFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");

                // Variable to save the folders.
                copiedFolderIds[index] = ((FolderInfoResponseMessageType)copyFolderResponse.ResponseMessages.Items[index]).Folders[0].FolderId;

                // Save the copied folders' folder id.
                this.NewCreatedFolderIds.Add(copiedFolderIds[index]);
            }

            #endregion

            #region Move the updated folders to "deleteditems" folder

            // MoveFolder request.
            MoveFolderType moveFolderRequest = new MoveFolderType();

            // Set the request's folderId field.
            moveFolderRequest.FolderIds = folderIds;

            // Set the request's destFolderId field.
            DistinguishedFolderIdType toFolderId = new DistinguishedFolderIdType();
            toFolderId.Id = DistinguishedFolderIdNameType.deleteditems;
            moveFolderRequest.ToFolderId      = new TargetFolderIdType();
            moveFolderRequest.ToFolderId.Item = toFolderId;

            // Move the specified folders.
            MoveFolderResponseType moveFolderResponse = this.FOLDAdapter.MoveFolder(moveFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(moveFolderResponse, 4, this.Site);

            for (int index = 0; index < moveFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, moveFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");
            }

            #endregion

            #region Delete all folders

            // All folder ids.
            FolderIdType[] allFolderIds = new FolderIdType[folderIds.Length + copiedFolderIds.Length];

            for (int index = 0; index < allFolderIds.Length / 2; index++)
            {
                allFolderIds[index] = folderIds[index];
                allFolderIds[index + folderIds.Length] = copiedFolderIds[index];
            }

            // DeleteFolder request.
            DeleteFolderType deleteFolderRequest = this.GetDeleteFolderRequest(DisposalType.HardDelete, allFolderIds);

            // Delete the specified folder.
            DeleteFolderResponseType deleteFolderResponse = this.FOLDAdapter.DeleteFolder(deleteFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(deleteFolderResponse, 8, this.Site);

            for (int index = 0; index < deleteFolderResponse.ResponseMessages.Items.Length; index++)
            {
                Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Success, deleteFolderResponse.ResponseMessages.Items[index].ResponseClass, "Folder should be updated successfully!");
            }

            #endregion
        }
        public void MSOXWSFOLD_S06_TC05_UpdateFolderWithMultipleProperties()
        {
            #region Create a new folder in the inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);
            FolderIdType             folderId             = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

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

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(folderId);

            #endregion

            #region Update Folder Operation.

            // UpdateFolder request.
            UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest("Folder", "SetFolderField", folderId);

            // In order to verify MS-OXWSCDATA_R335, add another property(PermissionSet) into UpdateFolder request.
            FolderType updatingFolder = (FolderType)((SetFolderFieldType)updateFolderRequest.FolderChanges[0].Updates[0]).Item1;
            updatingFolder.PermissionSet                = new PermissionSetType();
            updatingFolder.PermissionSet.Permissions    = new PermissionType[1];
            updatingFolder.PermissionSet.Permissions[0] = new PermissionType();
            updatingFolder.PermissionSet.Permissions[0].CanCreateSubFolders          = true;
            updatingFolder.PermissionSet.Permissions[0].CanCreateSubFoldersSpecified = true;
            updatingFolder.PermissionSet.Permissions[0].IsFolderOwner          = true;
            updatingFolder.PermissionSet.Permissions[0].IsFolderOwnerSpecified = true;
            updatingFolder.PermissionSet.Permissions[0].PermissionLevel        = new PermissionLevelType();
            updatingFolder.PermissionSet.Permissions[0].PermissionLevel        = PermissionLevelType.Custom;
            updatingFolder.PermissionSet.Permissions[0].UserId = new UserIdType();

            updatingFolder.PermissionSet.Permissions[0].UserId.PrimarySmtpAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);

            // Update the specific folder's properties.
            UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest);

            // Check the length.
            Site.Assert.AreEqual <int>(
                1,
                updateFolderResponse.ResponseMessages.Items.GetLength(0),
                "Expected Item Count: {0}, Actual Item Count: {1}",
                1,
                updateFolderResponse.ResponseMessages.Items.GetLength(0));

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

            // Verify MS-OXWSCDATA requirement: MS-OXWSCDATA_R335
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.ErrorIncorrectUpdatePropertyCount,
                updateFolderResponse.ResponseMessages.Items[0].ResponseCode,
                "MS-OXWSCDATA",
                335,
                @"[In m:ResponseCodeType Simple Type] The value ""ErrorIncorrectUpdatePropertyCount"" specifies that each change description in an UpdateItem or UpdateFolder method call MUST list only one property to be updated.");

            #endregion
        }
        public void MSOXWSFOLD_S06_TC01_UpdateFolder()
        {
            #region Create a new folder in the inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);
            FolderIdType             folderId             = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

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

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(folderId);

            #endregion

            #region Update Folder Operation.

            // UpdateFolder request.
            UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest("Folder", "SetFolderField", folderId);

            // Update the specific folder's properties.
            UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest);

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

            string updateNameInRequest = ((SetFolderFieldType)updateFolderRequest.FolderChanges[0].Updates[0]).Item1.DisplayName;
            #endregion

            #region Get the updated folder.

            // GetFolder request.
            GetFolderType getUpdatedFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folderId);

            // Get the updated folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getUpdatedFolderRequest);

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

            FolderInfoResponseMessageType allFolders = (FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0];
            FolderType gotFolderInfo = (FolderType)allFolders.Folders[0];

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R46444
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[0].ResponseClass,
                46444,
                @"[In UpdateFolder Operation]A successful UpdateFolder operation request returns an UpdateFolderResponse element with the ResponseClass attribute of the UpdateFolderResponseMessage element set to ""Success"".");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R4644
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                updateFolderResponse.ResponseMessages.Items[0].ResponseCode,
                4644,
                @"[In UpdateFolder Operation]A successful UpdateFolder operation request returns an UpdateFolderResponse element with the ResponseCode element of the UpdateFolderResponse element set to ""NoError"".");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R8902
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[0].ResponseClass,
                8902,
                @"[In t:FolderChangeType Complex Type]FolderId specifies the folder identifier and change key.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R582
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[0].ResponseClass,
                582,
                @"[In m:UpdateFolderType Complex Type]The UpdateFolderType complex type specifies a request message to update folders in a mailbox. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R534
            // Set a property on a FolderType folder successfully, indicates that Folder represents a regular folder.
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[0].ResponseClass,
                534,
                @"[In t:SetFolderFieldType Complex Type]Folder represents a regular folder in the server database.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R9301
            this.Site.CaptureRequirementIfAreEqual <string>(
                updateNameInRequest,
                gotFolderInfo.DisplayName,
                9301,
                @"[In t:FolderChangeType Complex Type][Updates] Specifies a collection of changes to a folder.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R546
            this.Site.CaptureRequirementIfAreEqual <string>(
                updateNameInRequest,
                gotFolderInfo.DisplayName,
                546,
                @"[In t:FolderChangeType Complex Type]The FolderChangeType complex type specifies a collection of changes to be performed on a single folder.");

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

            // All folders updated successfully!
            this.Site.CaptureRequirement(
                5051,
                @"[In m:UpdateFolderType Complex Type]FolderChanges represents an array of folders to be updated.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R531
            this.Site.CaptureRequirementIfAreEqual <string>(
                updateNameInRequest,
                gotFolderInfo.DisplayName,
                531,
                @"[In t:NonEmptyArrayOfFolderChangesType Complex Type]FolderChange represents a collection of changes to be performed on a single folder.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R5251
            this.Site.CaptureRequirementIfAreEqual <string>(
                updateNameInRequest,
                gotFolderInfo.DisplayName,
                5251,
                @"[In t:NonEmptyArrayOfFolderChangeDescriptionsType Complex Type]SetFolderField represents an UpdateFolder operation to set a property on an existing folder.");
        }
 /// <remarks/>
 public void CreateFolderAsync(CreateFolderType CreateFolder1)
 {
     this.CreateFolderAsync(CreateFolder1, null);
 }
        public void MSOXWSFOLD_S05_TC03_EmptyFolderMoveToDeletedItems()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");

            #region Create a new item and a new folder with an item in the Inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "ToBeDeleteFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            this.NewCreatedFolderIds.Add(newFolderId);

            string itemName1 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemInFolder = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName1);
            Site.Assert.IsNotNull(itemInFolder, "Item should be created successfully!");

            string itemName2 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in inbox.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), DistinguishedFolderIdNameType.inbox.ToString(), itemName2);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            // Variable to indicate whether the item2 is created properly.
            bool isItem2Created = this.FindItem(DistinguishedFolderIdNameType.inbox.ToString(), itemName2) != null;

            Site.Assert.IsTrue(isItem2Created, "The item should be created successfully in the specific folder.");

            #endregion

            #region Empty the inbox folder

            // Specify which folder will be emptied.
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;

            // Empty the specific folder
            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(folderId, DisposalType.MoveToDeletedItems, true);

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

            #endregion

            #region Get the folder in inbox folder to verify whether it has been deleted

            // GetFolder request.
            GetFolderType getFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the specific folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getFolderRequest);

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

            #endregion

            #region Find the item to see whether it has been deleted

            // Verify if item under inbox exists.
            ItemIdType itemIdAfterEmpty     = this.FindItem(DistinguishedFolderIdNameType.deleteditems.ToString(), itemName2);
            bool       isItemInDeletedItems = itemIdAfterEmpty != null;
            this.NewCreatedItemIds.Add(itemIdAfterEmpty);

            #endregion

            #region Get new created folder's parent folder

            GetFolderType getParentFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ParentFolderId);

            // Get the new created folder.
            GetFolderResponseType getParentFolderResponse = this.FOLDAdapter.GetFolder(getParentFolderRequest);

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

            string folderDisplayName = ((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].DisplayName;

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R37802
            bool isVerifiedR37802 = folderDisplayName.Equals("Deleted Items") && isItemInDeletedItems;

            Site.Assert.IsTrue(
                isVerifiedR37802,
                "Parent folder name after deleted expected to be \"Deleted Items\" and actual is {0};\n" +
                "Item in deleted items expected to be \"true\" and actual is {1};\n ",
                folderDisplayName,
                isItemInDeletedItems);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR37802,
                37802,
                @"[In m:EmptyFolderType Complex Type ]DeleteType which value is MoveToDeletedItems specifies that an item or folder is moved to the Deleted Items folder.");
        }
 /// <remarks/>
 public void CreateFolderAsync(CreateFolderType CreateFolder1, object userState)
 {
     if ((this.CreateFolderOperationCompleted == null))
     {
         this.CreateFolderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateFolderOperationCompleted);
     }
     this.InvokeAsync("CreateFolder", new object[] {
                 CreateFolder1}, this.CreateFolderOperationCompleted, userState);
 }
        public void MSOXWSFOLD_S05_TC01_EmptyFolder()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation");

            #region Create a new item and a new folder with an item in the Inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "ToBeDeleteFolder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

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

            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;

            string itemName1 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemInFolder = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName1);
            Site.Assert.IsNotNull(itemInFolder, "Item should be created successfully!");

            string itemName2 = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in inbox.
            ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), DistinguishedFolderIdNameType.inbox.ToString(), itemName2);
            Site.Assert.IsNotNull(itemId, "Item should be created successfully!");

            // Variable to indicate whether the item2 is created properly.
            bool isItem2Created = this.FindItem(DistinguishedFolderIdNameType.inbox.ToString(), itemName2) != null;

            Site.Assert.IsTrue(isItem2Created, "The item should be created successfully in the specific folder.");

            #endregion

            #region Empty the inbox folder

            // Specify which folder will be emptied.
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;

            // Empty the specific folder
            EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(folderId, DisposalType.HardDelete, true);

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

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R3474
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                emptyFolderResponse.ResponseMessages.Items[0].ResponseClass,
                3474,
                @"[In EmptyFolder Operation]A successful EmptyFolder operation request returns an EmptyFolderResponse element with the ResponseClass attribute of the EmptyFolderResponseMessage element set to ""Success"".");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R34744
            this.Site.CaptureRequirementIfAreEqual <ResponseCodeType>(
                ResponseCodeType.NoError,
                emptyFolderResponse.ResponseMessages.Items[0].ResponseCode,
                34744,
                @"[In EmptyFolder Operation]A successful EmptyFolder operation request returns an EmptyFolderResponse element with the ResponseCode element of the EmptyFolderResponse element set to ""NoError"".");

            #region Find the item in inbox to see whether it has been deleted

            // Verify if item under inbox exists.
            bool isInboxItemDeleted = this.IfItemDeleted(DistinguishedFolderIdNameType.inbox.ToString(), itemName2);

            #endregion

            #region Get the folder in inbox folder to verify whether it has been deleted

            // GetFolder request.
            GetFolderType getFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId);

            // Get the specific folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getFolderRequest);
            Site.Assert.AreEqual <ResponseClassType>(ResponseClassType.Error, getFolderResponse.ResponseMessages.Items[0].ResponseClass, "Folder information should not be returned! ");

            // Variable to indicate whether the folder in inbox folder is deleted.
            bool isFolderDeleted = getFolderResponse.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.ErrorItemNotFound;
            bool isItemDeleted   = isInboxItemDeleted && this.IfItemDeleted(DistinguishedFolderIdNameType.inbox.ToString(), itemName1);

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R367.
            bool isVerifyR367 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifyR367,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR367,
                367,
                @"[In Elements]EmptyFolder specifies a request to empty folders in a mailbox in the server store.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R571.
            bool isVerifyR571 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifyR571,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            Site.CaptureRequirementIfIsTrue(
                isVerifyR571,
                571,
                @"[In m:EmptyFolderType Complex Type]The EmptyFolderType complex type specifies a request message to empty a folder in a mailbox.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R380.
            // DeleteSubFolders has been set as true, if the subfolder is deleted, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isFolderDeleted,
                380,
                @"[In m:EmptyFolderType Complex Type]The DeleteSubFolders attribute is set to ""true"" if the subfolders are to be deleted.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R5664
            bool isVerifiedR5664 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifiedR5664,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR5664,
                5664,
                @"[In Appendix C: Product Behavior] Implementation does include the EmptyFolder operation.(Exchange Server 2010 SP2 and above follow this behavior.)");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R37801
            bool isVerifiedR37801 = isItemDeleted && isFolderDeleted;

            Site.Assert.IsTrue(
                isVerifiedR37801,
                "The expected result of deleting item should be \"true\", actual result is {0};\n" +
                "the expected result of deleting folder should be \"true\", actual result is {1}.\n ",
                isItemDeleted,
                isFolderDeleted);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR37801,
                37801,
                @"[In m:EmptyFolderType Complex Type ]DeleteType which value is HardDelete specifies that an item or folder is permanently removed from the store.");
        }
        /// <summary>
        /// Log on to a mailbox with a specified user account and create two different-level subfolders in the specified parent folder.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">Password of the user.</param>
        /// <param name="userDomain">Domain of the user.</param>
        /// <param name="parentFolderName">Name of the parent folder.</param>
        /// <param name="firstLevelSubFolderName">Name of the first level sub folder which will be created under the parent folder.</param>
        /// <param name="secondLevelSubFolderName">Name of the second level sub folder which will be created under the first level sub folder.</param>
        /// <returns>If the two level sub folders are created successfully, return true; otherwise, return false.</returns>
        public bool CreateSubFolders(string userName, string userPassword, string userDomain, string parentFolderName, string firstLevelSubFolderName, string secondLevelSubFolderName)
        {
            // Log on mailbox with specified user account(userName, userPassword, userDomain).
            bool isLoged = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site);

            Site.Assert.IsTrue(
                isLoged,
                string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain));

            // Initialize variables
            FolderIdType     folderId                        = null;
            CreateFolderType createFolderRequest             = new CreateFolderType();
            string           folderClassName                 = null;
            DistinguishedFolderIdNameType parentFolderIdName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), parentFolderName, true);

            // Define different folder class name according to different parent folder.
            switch (parentFolderIdName)
            {
            case DistinguishedFolderIdNameType.inbox:
                folderClassName = "IPF.Note";
                break;

            case DistinguishedFolderIdNameType.contacts:
                folderClassName = "IPF.Contact";
                break;

            case DistinguishedFolderIdNameType.calendar:
                folderClassName = "IPF.Appointment";
                break;

            case DistinguishedFolderIdNameType.tasks:
                folderClassName = "IPF.Task";
                break;

            default:
                Site.Assume.Fail(string.Format("The parent folder name '{0}' is invalid. Valid values are: inbox, contacts, calendar or tasks.", parentFolderName));
                break;
            }

            // Set parent folder ID.
            createFolderRequest.ParentFolderId = new TargetFolderIdType();
            DistinguishedFolderIdType parentFolder = new DistinguishedFolderIdType();

            parentFolder.Id = parentFolderIdName;
            createFolderRequest.ParentFolderId.Item = parentFolder;

            // Set Display Name and Folder Class for the folder to be created.
            FolderType folderProperties = new FolderType();

            folderProperties.DisplayName = firstLevelSubFolderName;
            folderProperties.FolderClass = folderClassName;

            createFolderRequest.Folders    = new BaseFolderType[1];
            createFolderRequest.Folders[0] = folderProperties;

            bool isSubFolderCreated = false;

            // Invoke CreateFolder operation and get the response.
            CreateFolderResponseType createFolderResponse = this.exchangeServiceBinding.CreateFolder(createFolderRequest);

            if (createFolderResponse != null && ResponseClassType.Success == createFolderResponse.ResponseMessages.Items[0].ResponseClass)
            {
                // If the first level sub folder is created successfully, save the folder ID of it.
                folderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
                FolderType created = new FolderType()
                {
                    DisplayName = folderProperties.DisplayName, FolderClass = folderClassName, FolderId = folderId
                };
                AdapterHelper.CreatedFolders.Add(created);
            }

            // Create another sub folder under the created folder above.
            if (folderId != null)
            {
                createFolderRequest.ParentFolderId.Item = folderId;
                folderProperties.DisplayName            = secondLevelSubFolderName;

                createFolderResponse = this.exchangeServiceBinding.CreateFolder(createFolderRequest);

                if (createFolderResponse != null && ResponseClassType.Success == createFolderResponse.ResponseMessages.Items[0].ResponseClass)
                {
                    // If the two level sub folders are created successfully, return true; otherwise, return false.
                    isSubFolderCreated = true;
                    folderId           = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
                    FolderType created = new FolderType()
                    {
                        DisplayName = folderProperties.DisplayName, FolderClass = folderClassName, FolderId = folderId
                    };
                    AdapterHelper.CreatedFolders.Add(created);
                }
            }

            return(isSubFolderCreated);
        }
        public void MSOXWSFOLD_S06_TC03_UpdateMultipleFolders()
        {
            #region Create a new folder in the inbox folder.

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(
                DistinguishedFolderIdNameType.inbox.ToString(),
                new string[] { "Custom Folder1", "Custom Folder2", "Custom Folder3", "Custom Folder4" },
                new string[] { "IPF.Appointment", "IPF.Contact", "IPF.Task", "IPF.Search" },
                null);

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(createFolderResponse, 4, this.Site);

            FolderIdType folderId1 = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            FolderIdType folderId2 = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[1]).Folders[0].FolderId;
            FolderIdType folderId3 = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[2]).Folders[0].FolderId;
            FolderIdType folderId4 = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[3]).Folders[0].FolderId;

            // Save the new created folder's folder id.
            this.NewCreatedFolderIds.Add(folderId1);
            this.NewCreatedFolderIds.Add(folderId2);
            this.NewCreatedFolderIds.Add(folderId3);
            this.NewCreatedFolderIds.Add(folderId4);

            #endregion

            #region Update Folder Operation.

            // UpdateFolder request.
            UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest(
                new string[] { "CalendarFolder", "ContactsFolder", "TasksFolder", "SearchFolder" },
                new string[] { "SetFolderField", "SetFolderField", "SetFolderField", "SetFolderField" },
                new FolderIdType[] { folderId1, folderId2, folderId3, folderId4 });

            // Update the specific folder's properties.
            UpdateFolderResponseType updateFolderResponse = this.FOLDAdapter.UpdateFolder(updateFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(updateFolderResponse, 4, this.Site);

            #endregion

            #region Get the updated folder.

            // GetFolder request.
            GetFolderType getUpdatedFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, folderId1, folderId2, folderId3, folderId4);

            // Get the updated folder.
            GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getUpdatedFolderRequest);

            // Check the response.
            Common.CheckOperationSuccess(getFolderResponse, 4, this.Site);

            FolderInfoResponseMessageType allPropertyOfSearchFolder = (FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[3];

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R33
            this.Site.CaptureRequirementIfIsInstanceOfType(
                allPropertyOfSearchFolder.Folders[0],
                typeof(SearchFolderType),
                33,
                @"[In t:ArrayOfFoldersType Complex Type]The type of element SearchFolder is t:SearchFolderType ([MS-OXWSSRCH] section 2.2.3.26).");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R3302
            this.Site.CaptureRequirementIfIsInstanceOfType(
                allPropertyOfSearchFolder.Folders[0],
                typeof(SearchFolderType),
                3302,
                @"[In t:ArrayOfFoldersType Complex Type]SearchFolder represents a search folder that is contained in a mailbox.");

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R536
            // Set a property on a CalendarFolderType folder successfully, indicates that Folder represents a regular folder.
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[0].ResponseClass,
                536,
                @"[In t:SetFolderFieldType Complex Type]CalendarFolder represents a folder that primarily contains calendar items. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R538
            // Set a property on a ContactFolderType folder successfully, indicates that Folder represents a regular folder.
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[1].ResponseClass,
                538,
                @"[In t:SetFolderFieldType Complex Type]ContactsFolder represents a Contacts folder in a mailbox. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R542
            // Set a property on a TaskFolderType folder successfully, indicates that Folder represents a regular folder.
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[2].ResponseClass,
                542,
                @"[In t:SetFolderFieldType Complex Type]TasksFolder represents a Tasks folder that is contained in a mailbox. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R540
            // Set a property on a SearchFolderType folder successfully, indicates that Folder represents a regular folder.
            this.Site.CaptureRequirementIfAreEqual <ResponseClassType>(
                ResponseClassType.Success,
                updateFolderResponse.ResponseMessages.Items[3].ResponseClass,
                540,
                @"[In t:SetFolderFieldType Complex Type]SearchFolder represents a search folder that is contained in a mailbox. ");
        }