Microsoft.Protocols.TestSuites.MS_OXWSCORE.S04_ManageEmailItems.MSOXWSCORE_S04_TC17_VerifyEmailWithResponseObjects C# (CSharp) Method

MSOXWSCORE_S04_TC17_VerifyEmailWithResponseObjects() private method

        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
        }