Microsoft.Protocols.TestSuites.MS_OXORULE.S02_ProcessServerSideRulesOtherthanOOF.MSOXORULE_S02_TC17_ServerExecuteRule_ForwardAsAttachment C# (CSharp) Method

MSOXORULE_S02_TC17_ServerExecuteRule_ForwardAsAttachment() private method

        public void MSOXORULE_S02_TC17_ServerExecuteRule_ForwardAsAttachment()
        {
            this.CheckMAPIHTTPTransportSupported();

            #region Prepare value for ruleProperties variable.
            RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameForwardAT);
            #endregion

            #region TestUser1 adds a rule for ActionType with OP_Forward ActionFlavor set to AT.
            ForwardDelegateActionData forwardActionData = new ForwardDelegateActionData
            {
                RecipientCount = (ushort)0x01
            };
            RecipientBlock recipientBlock = new RecipientBlock
            {
                Reserved = 0x01,
                NoOfProperties = (ushort)0x04u
            };

            #region Prepare the recipient Block of the rule to forward the message to TestUser2.
            TaggedPropertyValue[] recipientProperties = AdapterHelper.GenerateRecipientPropertiesBlock(this.User2Name, this.User2ESSDN);
            recipientBlock.PropertiesData = recipientProperties;

            #endregion

            forwardActionData.RecipientsData = new RecipientBlock[1] { recipientBlock };
            RuleData ruleForwardAT = AdapterHelper.GenerateValidRuleDataWithFlavor(ActionType.OP_FORWARD, 0, RuleState.ST_ENABLED, forwardActionData, (uint)ActionFlavorsForward.AT, ruleProperties);
            RopModifyRulesResponse ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForwardAT });
            Site.Assert.AreEqual<uint>(0, ropModifyRulesResponse.ReturnValue, "Adding Forward rule should succeed.");
            #endregion

            #region TestUser1 delivers a message to itself to trigger the rule.
            Thread.Sleep(this.WaitForTheRuleToTakeEffect);

            // TestUser1 delivers a message to itself to trigger the rule.
            string mailSubject = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName + "Title");
            this.SUTAdapter.SendMailToRecipient(this.User1Name, this.User1Password, this.User1Name, mailSubject);
            Thread.Sleep(this.WaitForTheRuleToTakeEffect);
            #endregion

            #region TestUser2 gets the forwarded message to verify the rule evaluation.

            // Let TestUser2 log on to the server.
            this.LogonMailbox(TestUser.TestUser2);
            PropertyTag[] propertyTagList = new PropertyTag[3];

            // pidTagSubject and pidTagMessageClass
            propertyTagList[0].PropertyId = (ushort)PropertyId.PidTagSubject;
            propertyTagList[0].PropertyType = (ushort)PropertyType.PtypString;
            propertyTagList[1].PropertyId = (ushort)PropertyId.PidTagMessageClass;
            propertyTagList[1].PropertyType = (ushort)PropertyType.PtypString;
            propertyTagList[2].PropertyId = (ushort)PropertyId.pidTagHasAttachment;
            propertyTagList[2].PropertyType = (ushort)PropertyType.PtypBoolean;
            uint contentsTableHandle = 0;
            int expectedMessageIndex = 0;
            RopQueryRowsResponse testUser2getNormalMailMessageContent = this.GetExpectedMessage(this.InboxFolderHandle, ref contentsTableHandle, propertyTagList, ref expectedMessageIndex, mailSubject);
            Site.Assert.AreEqual<uint>(0, testUser2getNormalMailMessageContent.ReturnValue, "Getting message property operation should succeed.");

            mailSubject = AdapterHelper.PropertyValueConvertToString(testUser2getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value);
            byte[] hasAttachment = testUser2getNormalMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[2].Value;

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

            // Verify MS-OXORULE requirement: MS-OXORULE_R279
            bool isVerifiedR279 = hasAttachment.Length == 1 && hasAttachment[0] == 1;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR279,
                279,
                @"[In Action Flavors] AT (Bitmask 0x00000004): Forwards the message as an attachment.");
            #endregion
        }