상속: BaseEmailAddressType
        /// <summary>
        /// Create item within a specific folder.
        /// </summary>
        /// <param name="toAddress">To address of created item</param>
        /// <param name="folderId">Parent folder id of the created item.</param>
        /// <param name="subject">Subject of the item.</param>
        /// <returns>Id of created item.</returns>
        protected ItemIdType CreateItem(string toAddress, string folderId, string subject)
        {
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.MessageDispositionSpecified = true;
            createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy;
            createItemRequest.SendMeetingInvitationsSpecified = true;
            createItemRequest.SavedItemFolderId = new TargetFolderIdType();

            DistinguishedFolderIdType distinguishedFolderId = new DistinguishedFolderIdType();
            DistinguishedFolderIdNameType distinguishedFolderIdName = new DistinguishedFolderIdNameType();
            bool isSuccess = Enum.TryParse<DistinguishedFolderIdNameType>(folderId, true, out distinguishedFolderIdName);

            if (isSuccess)
            {
                distinguishedFolderId.Id = distinguishedFolderIdName;
                createItemRequest.SavedItemFolderId.Item = distinguishedFolderId;
            }
            else
            {
                FolderIdType id = new FolderIdType();
                id.Id = folderId;
                createItemRequest.SavedItemFolderId.Item = id;
            }

            MessageType message = new MessageType();
            message.Subject = subject;
            EmailAddressType address = new EmailAddressType();
            address.EmailAddress = toAddress;

            // Set this message to unread.
            message.IsRead = false;
            message.IsReadSpecified = true;
            message.ToRecipients = new EmailAddressType[1];
            message.ToRecipients[0] = address;
            BodyType body = new BodyType();
            body.Value = Common.GenerateResourceName(this.Site, "Test Mail Body");
            message.Body = body;

            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[1];
            createItemRequest.Items.Items[0] = message;
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            ItemInfoResponseMessageType itemInfo = (ItemInfoResponseMessageType)createItemResponse.ResponseMessages.Items[0];

            // Return item id.
            if (itemInfo.Items.Items != null)
            {
                return itemInfo.Items.Items[0].ItemId;
            }
            else
            {
                return null;
            }
        }
        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
        }
        public void MSOXWSFOLD_S01_TC04_CreateManagedFolder()
        {
            #region Create a new managed folder

            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);

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

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

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R2692
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Success,
                createManagedFolderResponse.ResponseMessages.Items[0].ResponseClass,
                2692,
                @"[In CreateManagedFolder Operation]A successful CreateManagedFolder operation request returns a CreateManagedFolderResponse element with the ResponseClass attribute of the CreateManagedFolderResponseMessage element set to ""Success"".");

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

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

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R565
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Success,
                createManagedFolderResponse.ResponseMessages.Items[0].ResponseClass,
                565,
                @"[In m:CreateManagedFolderRequestType Complex Type]The CreateManagedFolderRequestType complex type specifies a request message to create a managed folder in a server database.");

            #region Get the new created managed folder to verify ManagedFolderInformationType

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

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

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

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R2961
            this.Site.CaptureRequirementIfAreEqual<string>(
                createManagedFolderRequest.FolderNames[0],
                ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].DisplayName,
                2961,
                @"[In m:CreateManagedFolderRequestType Complex Type]FolderNames specifies an array of managed folders to add to a mailbox. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R298
            // Because the email address is current user, so if this folder can be gotten by current user, this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Success,
                getFolderResponse.ResponseMessages.Items[0].ResponseClass,
                298,
                @"[In m:CreateManagedFolderRequestType Complex Type]Mailbox specifies the e-mail address of the mailbox in which the managed folders are added. ");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R5922
            // If ManagedFolderInformation is not null, this requirement will be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation,
                5922,
                @"[In t:BaseFolderType Complex Type]This property[ManagedFolderInformation] is returned in a response.");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R1111
            // Comment returned from server this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation.Comment,
                1111,
                @"[In t:ManagedFolderInformationType Complex Type]Comment is a comment that is associated with a managed folder.");

            #region Get the new created managed folder's parent folder

            FolderIdType parentFolderId = ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ParentFolderId;

            // GetFolder request.
            GetFolderType getParentFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, parentFolderId);

            // Get the specified managed folder's parent folder.
            GetFolderResponseType getParentFolderResponse = this.FOLDAdapter.GetFolder(getParentFolderRequest);

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

            Site.Assert.AreEqual<bool>(false, ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation.IsManagedFoldersRoot, "Folder should not be a root managed folder!");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R10811
            // Managed folder's parent folder is still a managed folder and its IsManagedFolderRoot is false, this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                ((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation,
                10811,
                @"[In t:ManagedFolderInformationType Complex Type][IsManagedFoldersRoot]A value of ""false"" indicates that the managed is not the root managed folder. ");

            bool isRootManagedFolderFound = true;

            // Loop to find the root managed folder.
            while (((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation.IsManagedFoldersRoot != true)
            {
                parentFolderId = ((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].ParentFolderId;
                if (parentFolderId == null)
                {
                    isRootManagedFolderFound = false;
                    break;
                }

                getParentFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, parentFolderId);
                getParentFolderResponse = this.FOLDAdapter.GetFolder(getParentFolderRequest);

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

                // If the folder is not a managed folder, break the loop
                if (((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation == null)
                {
                    isRootManagedFolderFound = false;
                    break;
                }
            }

            Site.Assert.AreEqual<bool>(true, isRootManagedFolderFound, "The root managed folder should exist!");

            #region Get the root managed folder's parent folder

            FolderIdType ancestorFolderId = ((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].ParentFolderId;

            // GetFolder request.
            GetFolderType getAncestorFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, ancestorFolderId);
            GetFolderResponseType getAncestorFolderResponse = this.FOLDAdapter.GetFolder(getAncestorFolderRequest);

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

            #endregion

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R1082
            // Root managed folder's parent folder is not a managed folder and Managed folder's parent folder's IsManagedFolderRoot is true, this requirement can be captured.
            this.Site.CaptureRequirementIfIsNull(
                ((FolderInfoResponseMessageType)getAncestorFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation,
                1082,
                @"[In t:ManagedFolderInformationType Complex Type][IsManagedFoldersRoot]A value of ""true"" indicates that the managed is the root managed folder. ");
        }
        /// <summary>
        /// Verify EmailAddressType type.
        /// </summary>
        /// <param name="emailAddress">An instance of EmailAddressType type.</param>
        /// <param name="isSchemaValidated">The result of schema validation, true means valid.</param>
        private void VerifyEmailAddressType(EmailAddressType emailAddress, bool isSchemaValidated)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1147");

            Site.CaptureRequirementIfIsTrue(
                isSchemaValidated,
                "MS-OXWSCDATA",
                1147,
                @"[In t:EmailAddessType Complex Type] The type [EmailAddressType] is defined as follow:
<xs:complexType name=""EmailAddressType"">
  <xs:complexContent>
    <xs:extension
      base=""t:BaseEmailAddressType""
    >
      <xs:sequence>
        <xs:element name=""Name""
          type=""xs:string""
          minOccurs=""0""
         />
        <xs:element name=""EmailAddress""
          type=""t:NonEmptyStringType""
          minOccurs=""0""
         />
        <xs:element name=""RoutingType""
          type=""t:NonEmptyStringType""
          minOccurs=""0""
         />
        <xs:element name=""MailboxType""
          type=""t:MailboxTypeType""
          minOccurs=""0""
         />
        <xs:element name=""ItemId""
          type=""t:ItemIdType""
          minOccurs=""0""
         />
        <xs:element name=""OriginalDisplayName"" 
          type=""xs:string"" 
          minOccurs=""0""/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>");

            if (!string.IsNullOrEmpty(emailAddress.EmailAddress))
            {
                this.VerifyNonEmptyStringType(isSchemaValidated);
            }

            if (emailAddress.MailboxTypeSpecified)
            {
                this.VerifyMailboxTypeType(isSchemaValidated);
            }

            if (!string.IsNullOrEmpty(emailAddress.RoutingType))
            {
                this.VerifyNonEmptyStringType(isSchemaValidated);
            }
        }
        public void MSOXWSFOLD_S01_TC19_VerifyStorageQuotaNotSet()
        {
            #region Create a new managed folder

            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);

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

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

            #region Get the new created managed folder to verify ManagedFolderInformationType

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

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

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

            ManagedFolderInformationType managedFolderInformation = ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation;

            Site.Assert.IsTrue(managedFolderInformation.HasQuotaSpecified && !managedFolderInformation.HasQuota, "The HasQuota element should be present!");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R10711
            this.Site.CaptureRequirementIfAreEqual(
                0,
                managedFolderInformation.StorageQuota,
                10711,
                @"[In t:ManagedFolderInformationType Complex Type][HasQuota]A value of ""false"" indicates that the StorageQuota property was not serialized into the SOAP response.");
            #endregion
        }
        public void MSOXWSFOLD_S01_TC20_VerifyStorageQuotaSet()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1121111, this.Site), "Exchange 2010 uses the StorageQuota which is the storage quota for a managed folder.");
 
            #region Create a new managed folder

            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;

            this.FOLDSUTControlAdapter.SetManagedFolderStoreQuota(createManagedFolderRequest.FolderNames[0]);

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

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

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

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

            #endregion

            #region Get the new created managed folder to verify ManagedFolderInformationType

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

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

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

            ManagedFolderInformationType managedFolderInformation = ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation;

            Site.Assert.IsTrue(managedFolderInformation.HasQuota, "The HasQuota element should be present!");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R1072
            this.Site.CaptureRequirementIfIsTrue(
                managedFolderInformation.HasQuota,
                1072,
                @"[In t:ManagedFolderInformationType Complex Type][HasQuota]A value of ""true"" indicates that the StorageQuota property was serialized into the SOAP response.");

            Site.Assert.IsTrue(managedFolderInformation.StorageQuotaSpecified && managedFolderInformation.StorageQuota != 0, "The StorageQuota element should be present!");

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

            // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R1121
            this.Site.CaptureRequirementIfAreEqual<int>(
                100,
                managedFolderInformation.StorageQuota,
                1121111,
                @"[In Appendix C: Product Behavior] Implementation does use StorageQuota which is the storage quota for a managed folder. (Exchange Server 2010 follow this behavior.)");
            #endregion

            #region Set the StoreQuota element to default value.
            this.FOLDSUTControlAdapter.DoNotSetManagedFolderStoreQuota(createManagedFolderRequest.FolderNames[0]);
            #endregion
        }
        public void MSOXWSCORE_S04_TC17_VerifyEmailWithResponseObjects()
        {
            #region Step 1: Create a message with IsReadReceiptRequested.
            // Define the MessageType item which will be created.
            MessageType[] messages = new MessageType[] { new MessageType() };
            messages[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            EmailAddressType email = new EmailAddressType();
            email.EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            messages[0].ToRecipients = new EmailAddressType[1];
            messages[0].ToRecipients[0] = email;
            messages[0].IsReadReceiptRequestedSpecified = true;
            messages[0].IsReadReceiptRequested = true;

            // Define the request of CreateItem operation.
            CreateItemType requestItem = new CreateItemType();
            requestItem.MessageDispositionSpecified = true;
            requestItem.MessageDisposition = MessageDispositionType.SendOnly;
            requestItem.Items = new NonEmptyArrayOfAllItemsType();
            requestItem.Items.Items = messages;

            // Call the CreateItem operation.
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(requestItem);

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

            #region Step 2: Get the message with response objects in inbox.
            // Find the received item in the Inbox folder.
            ItemIdType[] foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, messages[0].Subject, "User1");

            // The result of FindItemsInFolder should not be null.
            Site.Assert.IsNotNull(
                foundItems,
                "The result of FindItemsInFolder should not be null.");

            // One item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 foundItems.GetLength(0),
                 "One item should be returned! Expected count: {0}, actual count: {1}",
                 1,
                 foundItems.GetLength(0));

            // Get information from the found item.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(foundItems);

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

            // Check whether the child elements of ResponseObjects have been returned successfully.
            ItemInfoResponseMessageType getItems = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
            ResponseObjectType[] responseObjects = getItems.Items.Items[0].ResponseObjects;
 
            Site.Assert.IsNotNull(responseObjects, "The ResponseObjects should not be null.");

            // Receivers could reply, reply all, forward or send read receipt for the received item, so there should be four child elements in ResponseObjects.
            Site.Assert.AreEqual<int>(
                4,
                responseObjects.Length,
                "Four child elements in ResponseObjects should be returned! Expected count: {0}, actual count: {1}",
                4,
                responseObjects.Length);

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

            // The type of the child element should be ReplyToItemType, ForwardItemType, ReplyAllToItemType or SuppressReadReceiptType.
            foreach (ResponseObjectType responseObject in responseObjects)
            {
                if (responseObject.GetType() == typeof(ReplyToItemType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1371");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1371
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1371,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of ReplyToItem is t:ReplyToItemType ([MS-OXWSCDATA] section 2.2.4.56).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R131
                    // The response object with ReplyToItemType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        131,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""ReplyToItem""] Specifies a reply to the sender of an item.");
                }
                else if (responseObject.GetType() == typeof(ForwardItemType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1372");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1372
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1372,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of ForwardItem is t:ForwardItemType ([MS-OXWSCDATA] section 2.2.4.33).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R132
                    // The response object with ForwardItemType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        132,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""ForwardItem""] Specifies a server store item to be forwarded to recipients.");
                }
                else if (responseObject.GetType() == typeof(ReplyAllToItemType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1373");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1373
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1373,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of ReplyAllToItem is t:ReplyAllToItemType ([MS-OXWSCDATA] section 2.2.4.54).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R133
                    // The response object with ReplyAllToItemType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        133,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""ReplyAllToItem""] Specifies a reply to the sender and all identified recipients of an item in the server store.");
                }
                else if (responseObject.GetType() == typeof(SuppressReadReceiptType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1376");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1376
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1376,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of SuppressReadReceipt is t:SuppressReadReceiptType ([MS-OXWSCDATA] section 2.2.4.61).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R136
                    // The response object with SuppressReadReceiptType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        136,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""SuppressReadReceipt""] Specifies that read receipts are to be suppressed.");
                }
                else
                {
                    Site.Assume.Fail(
                        string.Format(
                        "The type of responseObject should be one of the following types: ReplyToItemType, ForwardItemType, ReplyAllToItemType or SuppressReadReceiptType, actual {0}",
                        responseObject.GetType()));
                }
            }
            #endregion

            #region Step 3: Delete messages in inbox.
            // Delete the created item.
            this.COREAdapter.DeleteItem(new DeleteItemType() { DeleteType = DisposalType.HardDelete, ItemIds = foundItems });
            this.ExistItemIds.Clear();
            this.FindNewItemsInFolder(DistinguishedFolderIdNameType.inbox);
            #endregion
        }
        public void MSOXWSFOLD_S01_TC18_VerifyRenameOrMoveFalse()
        {
            #region Create a new managed folder

            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);

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

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

            #endregion

            #region Get the new created managed folder to verify ManagedFolderInformationType

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

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

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

            #endregion

            #region Get the new created managed folder's parent folder

            FolderIdType parentFolderId = ((FolderInfoResponseMessageType)getFolderResponse.ResponseMessages.Items[0]).Folders[0].ParentFolderId;

            // GetFolder request.
            GetFolderType getParentFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, parentFolderId);

            // Get the specified managed folder's parent folder.
            GetFolderResponseType getParentFolderResponse = this.FOLDAdapter.GetFolder(getParentFolderRequest);

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

            #region Move the new created folder to the inbox folder
            ManagedFolderInformationType managedFolderInformation = ((FolderInfoResponseMessageType)getParentFolderResponse.ResponseMessages.Items[0]).Folders[0].ManagedFolderInformation;

            if (Common.IsRequirementEnabled(1051112, this.Site))
            {
                // MoveFolder request.
                MoveFolderType moveFolderRequest = new MoveFolderType();

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

                // 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.
                Site.Assert.AreEqual<ResponseClassType>(ResponseClassType.Error, moveFolderResponse.ResponseMessages.Items[0].ResponseClass, "Managed folder should not be moved");

                Site.Assert.IsTrue(managedFolderInformation.CanRenameOrMoveSpecified && !managedFolderInformation.CanRenameOrMove, "The CanRenameOrMove element should be present!");

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

                // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R1051112
                this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                    ResponseClassType.Error,
                    moveFolderResponse.ResponseMessages.Items[0].ResponseClass,
                    1051112,
                    @"[In Appendix C: Product Behavior] Implementation does support value of ""false"" for CanRenameOrMove to indicate that the managed folder can not be moved. (Exchange 2007, Exchange 2010 and Exchange2013 follow this behavior)");
                }
            #endregion

            #region Update Folder Operation.
            if (Common.IsRequirementEnabled(1051111, this.Site))
            {
                // UpdateFolder request.
                UpdateFolderType updateFolderRequest = this.GetUpdateFolderRequest("Folder", "SetFolderField", parentFolderId);

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

                Site.Assert.AreEqual<ResponseClassType>(ResponseClassType.Error, updateFolderResponse.ResponseMessages.Items[0].ResponseClass, "Managed folder should not be updated");

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

                // Verify MS-OXWSFOLD requirement: MS-OXWSFOLD_R1051111
                this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                    ResponseClassType.Error,
                    updateFolderResponse.ResponseMessages.Items[0].ResponseClass,
                    1051111,
                    @"[In Appendix C: Product Behavior] Implementation does support value of ""false"" for CanRenameOrMove to indicate that the managed folder can not be renamed. (Exchange 2007, Exchange 2010 and Exchange2013 follow this behavior.)");
            }
            #endregion
        }
        public void MSOXWSCORE_S04_TC25_UpdateItemWithSuppressReadReceipts()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2315, this.Site), "Exchange 2007, Exchange 2010, and the initial release of Exchange 2013 do not support the SuppressReadReceipts attribute.");

            #region Send an email with setting IsReadReceiptRequested to true.

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

            #endregion

            #region Find the email in receiver's inbox.

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

            #endregion

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

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

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

            #region Send an email with setting IsReadReceiptRequested to true.

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

            #endregion

            #region Find the email in receiver's inbox.

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

            #endregion

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

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

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2315
            // This requirement can be captured directly after above steps.
            this.Site.CaptureRequirement(
                2315,
                @"[In Appendix C: Product Behavior] Implementation does  support the SuppressReadReceipts attribute specifies whether read receipts are suppressed. (<102> Section 3.1.4.9.3.2:  This attribute [SuppressReadReceipts] was introduced in Exchange 2013 SP1.)");
            #endregion
        }
        public void MSOXWSCORE_S04_TC09_OperateMultipleEmailItemsSuccessfully()
        {
            #region Step 1: Create multiple items.
            EmailAddressType address = new EmailAddressType()
            {
                EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site),
            };

            MessageType[] items = new MessageType[]
            {
                new MessageType
                {
                    Subject = Common.GenerateResourceName(
                        this.Site,
                        TestSuiteHelper.SubjectForCreateItem,
                        1),

                    ToRecipients = new EmailAddressType[]
                    {
                        address
                    }
                },
                new MessageType
                {
                    Subject = Common.GenerateResourceName(
                        this.Site,
                        TestSuiteHelper.SubjectForCreateItem,
                        2),

                    ToRecipients = new EmailAddressType[]
                    {
                        address
                    }
                }
            };

            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.drafts, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 2, this.Site);

            ItemType[] createdItems = Common.GetItemsFromInfoResponse<ItemType>(createItemResponse);

            // Two created items should be returned.
            Site.Assert.AreEqual<int>(
                    2,
                    createdItems.GetLength(0),
                    "Two created item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                    2,
                    createdItems.GetLength(0));
            #endregion

            #region Step 2 - 5: Update, move, get and copy the items.
            this.OperateMultipleItems(createdItems);
            #endregion

            #region Step 6: Send the items and clean the items sent out.
            // Call SendItem to send the created message items from Inbox folder to the recipient identified by the ToRecipients element, by using createdItemIds in CreateItem response.
            ItemIdType[] itemArray = new ItemIdType[this.CopiedItemIds.Count];
            this.CopiedItemIds.CopyTo(itemArray, 0);
            SendItemResponseType sendResponse = this.CallSendItemOperation(
                itemArray,
                DistinguishedFolderIdNameType.sentitems,
                false);

            // Check the operation response.
            Common.CheckOperationSuccess(sendResponse, 2, this.Site);

            // Remove the sent items from ExistItemIds collection, since the items have been sent out and no copy remains.
            foreach (ItemIdType itemId in itemArray)
            {
                this.ExistItemIds.Remove(itemId);
            }

            // Clear the sent items.
            string[] itemSubjects = new string[2];
            itemSubjects[0] = items[0].Subject;
            itemSubjects[1] = items[1].Subject;
            this.CleanItemsSentOut(itemSubjects);
            #endregion
        }
        public void MSOXWSCORE_S04_TC24_DeleteItemWithSuppressReadReceipts()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2311, this.Site), "Exchange 2007, Exchange 2010, and the initial release of Exchange 2013 do not support the SuppressReadReceipts attribute.");

            #region Send an email with setting IsReadReceiptRequested to true.

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

            #endregion

            #region Find the email in receiver's inbox.

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

            #endregion

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

            DeleteItemType deleteItemRequest = new DeleteItemType();
            deleteItemRequest.ItemIds = findItemIds;
            deleteItemRequest.DeleteType = DisposalType.HardDelete;
            deleteItemRequest.SuppressReadReceiptsSpecified = true;
            deleteItemRequest.SuppressReadReceipts = true;
            DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest);
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.IsNull(findItemIds, "The read receipt email should not be received if receiver delete the email with setting SuppressReadReceipts to true.");

            #endregion

            #region Send an email with setting IsReadReceiptRequested to true.

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

            #endregion

            #region Find the email in receiver's inbox.

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

            #endregion

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

            deleteItemRequest.ItemIds = findItemIds;
            deleteItemRequest.SuppressReadReceipts = false;
            deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest);
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.AreEqual<int>(1, findItemIds.Length, "The read receipt email should be received if receiver delete the email with setting SuppressReadReceipts to false.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2311
            // This requirement can be captured directly after above steps.
            this.Site.CaptureRequirement(
                2311,
                @"[In Appendix C: Product Behavior] Implementation does support the SuppressReadReceipts attribute which specifies whether read receipts are suppressed. (Exchange 2013 SP1 and above follow this behavior.)");

            #endregion
        }
        public void MSOXWSCORE_S04_TC22_VerifyItemWithEntityExtractionResult()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1708, this.Site), "Exchange 2007 and Exchange 2010 do not support the EntityExtractionResultType complex type.");

            #region Step 1: Create message with specific body.

            // Define the specific elements' values.
            string meetingSuggestions = "Let's meet for business discussion, from 2:00pm to 2:30pm, December 15th, 2012.";
            string address = "1234 Main Street, Redmond, WA 07722";
            string taskSuggestions = "Please update the spreadsheet by today.";
            string phoneNumbers = "(235) 555-0110";
            string phoneNumberType = "Home";
            string businessName = "Department of Revenue Services";
            string contactDisplayName = TestSuiteHelper.ContactString;
            string emailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            string url = Common.GetConfigurationPropertyValue("ServiceUrl", this.Site);
            string userEmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);

            // Define the MessageType item which will be created.
            MessageType[] messages = new MessageType[] { new MessageType() };
            messages[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            EmailAddressType email = new EmailAddressType();
            email.EmailAddress = userEmailAddress;
            messages[0].ToRecipients = new EmailAddressType[1];
            messages[0].ToRecipients[0] = email;
            messages[0].Body = new BodyType();
            messages[0].Body.Value = string.Format(
                "{0} {1} Any problems, contact with {2} from {3}, his {4} phone number is {5}, his email is {6}, his blog is {7} and his address is {8}",
                meetingSuggestions,
                taskSuggestions,
                contactDisplayName,
                businessName,
                phoneNumberType,
                phoneNumbers,
                emailAddress,
                url,
                address);

            // Define the request of CreateItem operation.
            CreateItemType requestItem = new CreateItemType();
            requestItem.MessageDispositionSpecified = true;
            requestItem.MessageDisposition = MessageDispositionType.SendOnly;
            requestItem.Items = new NonEmptyArrayOfAllItemsType();
            requestItem.Items.Items = messages;

            // Call the CreateItem operation.
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(requestItem);

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

            #region Step 2: Find the message in the inbox folder of User1.
            // Find the received item in the Inbox folder.
            ItemIdType[] foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, messages[0].Subject, "User1");

            // The result of FindItemsInFolder should not be null.
            Site.Assert.IsNotNull(
                foundItems,
                "The result of FindItemsInFolder should not be null.");

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

            #region Step 3: Get the message.
            // Get information from the found items.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(foundItems);

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

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

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

            // Check whether the child elements of EntityExtractionResultType have been returned successfully.
            ItemInfoResponseMessageType getItems = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;

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

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1325
            // The schema is validated and InternetMessageHeaders is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                getItems.Items.Items[0].InternetMessageHeaders,
                1325,
                @"[In t:ItemType Complex Type] The type of InternetMessageHeaders is t:NonEmptyArrayOfInternetHeadersType (section 2.2.4.12).");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R122
            // The schema is validated and InternetMessageHeaders is not null, so this requirement can be captured.
            this.Site.CaptureRequirement(
                122,
                @"[In t:NonEmptyArrayOfInternetHeadersType Complex Type] The type [NonEmptyArrayOfInternetHeadersType] is defined as follow:
<xs:complexType name=""NonEmptyArrayOfInternetHeadersType"">
  <xs:sequence>
    <xs:element name=""InternetMessageHeader""
      type=""t:InternetHeaderType""
      maxOccurs=""unbounded""
     />
  </xs:sequence>
</xs:complexType>");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R20301
            // MS-OXWSCORE_R1325 is captured, this requirement can be captured directly.
            this.Site.CaptureRequirement(
                20301,
                @"[In t:ItemType Complex Type] It [InternetMessageHeaders] can be retrieved by GetItem (section 3.1.4.4) operation.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1367
            // The schema is validated and InternetMessageHeaders is not null, so this requirement can be captured.
            this.Site.CaptureRequirement(
                1367,
                @"[In t:NonEmptyArrayOfInternetHeadersType Complex Type] The type of InternetMessageHeader is t:InternetHeaderType([MS-OXWSCDATA] section 2.2.4.35).");

            foreach (InternetHeaderType internetMessageHeader in getItems.Items.Items[0].InternetMessageHeaders)
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1674");

                // Verify MS-OXWSCDATA requirement: MS-OXWSCDATA_R1674
                // The schema is validated and the internetMessageHeader is not null, so this requirement can be captured.
                this.Site.CaptureRequirementIfIsNotNull(
                    internetMessageHeader,
                    "MS-OXWSCDATA",
                    1674,
                    @"[In t:InternetHeaderType Complex Type] The attribute ""HeaderName"" is ""xs:string"" type.");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R88");
                this.Site.Log.Add(LogEntryKind.Debug, "The HeaderName should not be null, actual {0}.", internetMessageHeader.HeaderName);
                this.Site.Log.Add(LogEntryKind.Debug, "The Value should not be null, actual {0}.", internetMessageHeader.Value);

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R88
                // The schema is validated and the child elements in internetMessageHeader are not null, so this requirement can be captured.
                bool isVerifiedR88 = internetMessageHeader.HeaderName != null && internetMessageHeader.Value != null;

                this.Site.CaptureRequirementIfIsTrue(
                    isVerifiedR88,
                    88,
                    @"[In t:ItemType Complex Type] [The element ""InternetMessageHeaders""] Specifies an array of the type InternetHeaderType that represents the collection of all Internet message headers that are contained in an item in a mailbox.");

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

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R124
                this.Site.CaptureRequirement(
                    124,
                    @"[In t:NonEmptyArrayOfInternetHeadersType Complex Type] [The element ""InternetMessageHeader""] Specifies a single Internet message header.");
            }

            EntityExtractionResultType entityExtractionResult = getItems.Items.Items[0].EntityExtractionResult;

            // Verify EntityExtractionResultType structure.
            this.VerifyEntityExtractionResultType(entityExtractionResult);

            // Verify ArrayOfAddressEntitiesType structure.
            this.VerifyArrayOfAddressEntitiesType(entityExtractionResult.Addresses, address);

            // Verify ArrayOfMeetingSuggestionsType structure.
            // "2:00pm, December 15th, 2012" is supposed to be "2012/12/15 14:00:00" in dataTime type.
            // "2:30pm, December 15th, 2012" is supposed to be "2012/12/15 14:30:00" in dataTime type.
            this.VerifyArrayOfMeetingSuggestionsType(entityExtractionResult.MeetingSuggestions, meetingSuggestions, DateTime.Parse("2012/12/15 14:00:00"), DateTime.Parse("2012/12/15 14:30:00"), Common.GetConfigurationPropertyValue("User1Name", this.Site), userEmailAddress);

            // Verify ArrayOfTaskSuggestionsType structure.
            this.VerifyArrayOfTaskSuggestionsType(entityExtractionResult.TaskSuggestions, taskSuggestions, Common.GetConfigurationPropertyValue("User1Name", this.Site), userEmailAddress);

            // Verify ArrayOfEmailAddressEntitiesType structure.
            this.VerifyArrayOfEmailAddressEntitiesType(entityExtractionResult.EmailAddresses, emailAddress);

            // Verify ArrayOfContactsType structure.
            Uri uri = new Uri(url);
            this.VerifyArrayOfContactsType(entityExtractionResult.Contacts, contactDisplayName, businessName, uri, phoneNumbers, phoneNumberType, emailAddress, address);

            // Verify ArrayOfUrlEntitiesType structure.
            this.VerifyArrayOfUrlEntitiesType(entityExtractionResult.Urls, uri);

            // Verify ArrayOfPhoneEntitiesType structure.
            this.VerifyArrayOfPhoneEntitiesType(entityExtractionResult.PhoneNumbers, phoneNumbers, phoneNumberType);
            #endregion
        }
        public void MSOXWSCORE_S04_TC21_VerifyItemWithIsDraftAndIsUnmodified()
        {
            #region Step 1: Create the item which will be saved.
            // Define the MessageType item to create.
            EmailAddressType addressTo = new EmailAddressType();
            addressTo.EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            EmailAddressType addressCc = new EmailAddressType();
            addressCc.EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            MessageType[] message = new MessageType[1]
            {
                new MessageType
                {
                    ToRecipients = new EmailAddressType[] { addressTo, addressCc },
                    CcRecipients = new EmailAddressType[] { addressCc, addressTo },
                    Subject = Common.GenerateResourceName(this.Site, "ItemSaveOnly")
                }
            };

            // Call the CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.inbox, message);

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

            ItemIdType[] createdItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

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

            #region Step 2: Get the created item.
            // Call the GetItem operation.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(createdItemIds);

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

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

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

            // If the item is saved, the IsDraft element should be true and the IsUnmodified element should be false.
            ItemInfoResponseMessageType itemInfoResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
            ArrayOfRealItemsType arrayOfRealItemsType = itemInfoResponseMessage.Items;

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

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1608, Expected result:{0}, Actual result:{1}", true, arrayOfRealItemsType.Items[0].IsDraft);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1608
            bool isVerifiedR1608 = arrayOfRealItemsType.Items[0].IsDraftSpecified && arrayOfRealItemsType.Items[0].IsDraft;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1608,
                1608,
                @"[In t:ItemType Complex Type] [IsDraft is] True, indicates an item has not been sent.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1615, Expected result:{0}, Actual result:{1}", false, arrayOfRealItemsType.Items[0].IsUnmodified);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1615
            bool isVerifiedR1615 = arrayOfRealItemsType.Items[0].IsUnmodifiedSpecified && !arrayOfRealItemsType.Items[0].IsUnmodified;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1615,
                1615,
                @"[In t:ItemType Complex Type] otherwise [IsUnmodified is] false, indicates [an item has been modified].");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R96
            // The schema is validated, the DisplayCc element is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                arrayOfRealItemsType.Items[0].DisplayCc,
                96,
                @"[In t:ItemType Complex Type] [The element ""DisplayCc""] Specifies the display string that is used for the contents of the Cc box.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R97
            // The schema is validated, the DisplayCc element is concatenated by the display names of all Cc recipients, so this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual<string>(
                (Common.GetConfigurationPropertyValue("User2Name", this.Site) + "; " + Common.GetConfigurationPropertyValue("User1Name", this.Site)).ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                arrayOfRealItemsType.Items[0].DisplayCc.ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                97,
                @"[In t:ItemType Complex Type] This [DisplayCc] is the concatenated string of all Cc recipient display names.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R98
            // The schema is validated, the DisplayTo element is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                arrayOfRealItemsType.Items[0].DisplayTo,
                98,
                @"[In t:ItemType Complex Type] [The element ""DisplayTo""] Specifies the display string that is used for the contents of the To box.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R99
            // The schema is validated, the DisplayTo element is concatenated by the display names of all To recipients, so this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual<string>(
                (Common.GetConfigurationPropertyValue("User1Name", this.Site) + "; " + Common.GetConfigurationPropertyValue("User2Name", this.Site)).ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                arrayOfRealItemsType.Items[0].DisplayTo.ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                99,
                @"[In t:ItemType Complex Type] This [DisplayTo] is the concatenated string of all To recipient display names.");
            #endregion

            #region Step 3: Create the item which will be sent.
            // Define the CreateItem request.
            CreateItemType requestItem = new CreateItemType();
            requestItem.MessageDispositionSpecified = true;
            requestItem.MessageDisposition = MessageDispositionType.SendOnly;
            requestItem.Items = new NonEmptyArrayOfAllItemsType();
            message = new MessageType[1]
            {
                new MessageType
                {
                    ToRecipients = new EmailAddressType[] { addressTo },
                    Subject = Common.GenerateResourceName(this.Site, "ItemSendOnly")
                }
            };
            requestItem.Items.Items = message;

            // Call the CreateItem operation.
            createItemResponse = this.COREAdapter.CreateItem(requestItem);

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

            #region Step 4: Get the received item.
            // Find the received item in the Inbox folder.
            ItemIdType[] findItem = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, message[0].Subject, "User1");

            // The result of FindItemsInFolder should not be null.
            Site.Assert.IsNotNull(
                findItem,
                "The result of FindItemsInFolder should not be null.");

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

            // Get the found item.
            getItemResponse = this.CallGetItemOperation(findItem);

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

            getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse);

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

            // If the item is sent, the IsDraft element should be false and the IsUnmodified element should be true.
            itemInfoResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
            arrayOfRealItemsType = itemInfoResponseMessage.Items;

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

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1609, Expected result:{0}, Actual result:{1}", false, arrayOfRealItemsType.Items[0].IsDraft);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1609
            bool isVerifiedR1609 = arrayOfRealItemsType.Items[0].IsDraftSpecified && !arrayOfRealItemsType.Items[0].IsDraft;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1609,
                1609,
                @"[In t:ItemType Complex Type] otherwise [IsDraft is] false, indicates [an item has been sent].");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1614, Expected result:{0}, Actual result:{1}", true, arrayOfRealItemsType.Items[0].IsUnmodified);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1614
            bool isVerifiedR1614 = arrayOfRealItemsType.Items[0].IsUnmodifiedSpecified && arrayOfRealItemsType.Items[0].IsUnmodified;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1614,
                1614,
                @"[In t:ItemType Complex Type] [IsUnmodified is] True, indicates an item has not been modified.");
            #endregion
        }
        public void MSOXWSCORE_S05_TC21_ResponseObjectsProposeNewTime()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2302, this.Site), "Exchange 2007, Exchange 2010, and the initial release of Exchange 2013 do not support the ProposeNewTime element. ");

            #region Organizer sends meeting to attendee.
            CalendarItemType item = new CalendarItemType();
            item.RequiredAttendees = new AttendeeType[1];
            EmailAddressType attendeeEmail = new EmailAddressType();
            attendeeEmail.EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            AttendeeType attendee = new AttendeeType();
            attendee.Mailbox = attendeeEmail;
            item.RequiredAttendees[0] = attendee;

            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { item };
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem);
            createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendOnlyToAll;
            createItemRequest.SendMeetingInvitationsSpecified = true;

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

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

            ItemIdType[] createdItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

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

            #region Attendee gets the meeting request
            ItemIdType[] findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2");
            Site.Assert.AreEqual<int>(1, findItemIds.Length, "Attendee should receive the meeting request");

            GetItemResponseType getItemResponse = this.CallGetItemOperation(findItemIds);

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

            // Check whether the child elements of ResponseObjects have been returned successfully.
            ItemInfoResponseMessageType getItems = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
            ResponseObjectType[] responseObjects = getItems.Items.Items[0].ResponseObjects;
            foreach (ResponseObjectType responseObject in responseObjects)
            {
                if (responseObject.GetType() == typeof(ProposeNewTimeType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R2302");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2302
                    // Element ProposeNewTime is returned from server, this requirement can be captured directly.
                    this.Site.CaptureRequirement(
                        2302,
                        @"[In Appendix C: Product Behavior] Implementation does support the ProposeNewTime element which specifies the response object that is used to propose a new time. (<82> Section 2.2.4.33:  This element [ProposeNewTime] was introduced in Exchange 2013 SP1.)");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2135
                    // Element ProposeNewTime is returned from server and pass schema validation, this requirement can be captured directly.
                    this.Site.CaptureRequirement(
                        2135,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of ProposeNewTime is t:ProposeNewTimeType ([MS-OXWSCDATA] section 2.2.4.38).");
                    break;
                }
            }

            this.CleanItemsSentOut(new string[] { createItemRequest.Items.Items[0].Subject });
            this.ExistItemIds.Remove(getItems.Items.Items[0].ItemId);
            #endregion
        }
        /// <summary>
        /// Verify EmailAddressType structure.
        /// </summary>
        /// <param name="emailAddressType">The EmailAddressType object.</param>
        /// <param name="isSchemaValidated">The result of schema validation, true means valid.</param>
        private void VerifyEmailAddressType(EmailAddressType emailAddressType, bool isSchemaValidated)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1147");

            // Verify MS-OXWSCDATA requirement: MS-OXWSCDATA_R1147
            // The EmailAddressType is the type of Mailbox contained in CalendarItemType and MeetingRequestMessageType. If schema verification passes, it indicates the schemas of contained elements are also verified.
            Site.CaptureRequirementIfIsTrue(
                isSchemaValidated,
                "MS-OXWSCDATA",
                1147,
                @"[In t:EmailAddessType Complex Type] The type [EmailAddressType] is defined as follow:
<xs:complexType name=""EmailAddressType"">
  <xs:complexContent>
    <xs:extension
      base=""t:BaseEmailAddressType""
    >
      <xs:sequence>
        <xs:element name=""Name""
          type=""xs:string""
          minOccurs=""0""
         />
        <xs:element name=""EmailAddress""
          type=""t:NonEmptyStringType""
          minOccurs=""0""
         />
        <xs:element name=""RoutingType""
          type=""t:NonEmptyStringType""
          minOccurs=""0""
         />
        <xs:element name=""MailboxType""
          type=""t:MailboxTypeType""
          minOccurs=""0""
         />
        <xs:element name=""ItemId""
          type=""t:ItemIdType""
          minOccurs=""0""
         />
        <xs:element name=""OriginalDisplayName"" 
          type=""xs:string"" 
          minOccurs=""0""/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>");

            if (emailAddressType.MailboxTypeSpecified == true)
            {
                this.VerifyMailboxTypeType(isSchemaValidated);
            }

            if (emailAddressType.EmailAddress != null || emailAddressType.RoutingType != null)
            {
                this.VerifyNonEmptyStringType(isSchemaValidated);
            }
        }