public void MSOXORULE_S02_TC09_ServerExecuteRule_Action_OP_TAG()
{
this.CheckMAPIHTTPTransportSupported();
#region Prepare value for ruleProperties variable.
RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameTag);
#endregion
#region TestUser1 adds an OP_TAG rule to the Inbox folder.
TagActionData tagActionData = new TagActionData();
PropertyTag tagActionDataPropertyTag = new PropertyTag
{
PropertyId = (ushort)PropertyId.PidTagImportance,
PropertyType = (ushort)PropertyType.PtypInteger32
};
tagActionData.PropertyTag = tagActionDataPropertyTag;
tagActionData.PropertyValue = BitConverter.GetBytes(2);
RuleData ruleOpTag = AdapterHelper.GenerateValidRuleData(ActionType.OP_TAG, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, tagActionData, ruleProperties, null);
RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleOpTag });
Site.Assert.AreEqual<uint>(0, modifyRulesResponse.ReturnValue, "Adding OP_TAG rule should succeed.");
#endregion
#region TestUser2 delivers a message to TestUser1.
// Wait for the mail to be received and the rule to take effect.
Thread.Sleep(this.WaitForTheRuleToTakeEffect);
string mailSubject = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName + "Title");
// TestUser2 delivers a message to trigger these rules.
this.SUTAdapter.SendMailToRecipient(this.User2Name, this.User2Password, this.User1Name, mailSubject);
// Wait for the mail to be received and the rule to take effect.
Thread.Sleep(this.WaitForTheRuleToTakeEffect);
#endregion
#region TestUser1 gets the message and its properties to verify the rule evaluation.
PropertyTag[] propertyTagList = new PropertyTag[2];
propertyTagList[0].PropertyId = (ushort)PropertyId.PidTagImportance;
propertyTagList[0].PropertyType = (ushort)PropertyType.PtypInteger32;
propertyTagList[1].PropertyId = (ushort)PropertyId.PidTagSubject;
propertyTagList[1].PropertyType = (ushort)PropertyType.PtypString;
uint contentTableHandle = 0;
int expectedMessageIndex = 0;
RopQueryRowsResponse getMailMessageContent = this.GetExpectedMessage(this.InboxFolderHandle, ref contentTableHandle, propertyTagList, ref expectedMessageIndex, mailSubject);
// Add the debug information.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R548: the value of PidTagImportance is {0}", BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0));
// Verify MS-OXORULE requirement: MS-OXORULE_R548.
// If the PidTagImportance is 2 which is set on OP_TAG rule, it means the rule tacks action and the rule sets the property specified in the rule's action buffer structure.
bool isVerifyR548 = BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0) == 2;
Site.CaptureRequirementIfIsTrue(
isVerifyR548,
548,
@"[In Processing Incoming Messages to a Folder] [Following is a description of what the server does when it executes each action (2) type, as specified in section 2.2.5.1.1, for an incoming message] ""OP_TAG"": The server MUST set on the message the property specified in the action buffer structure.");
// Add the debug information.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R266: the value of PidTagImportance is {0}", BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0));
// Verify MS-OXORULE requirement: MS-OXORULE_R266.
// If the PidTagImportance is 2 which is set on OP_TAG rule, it means the rule tacks action and the rule sets the property specified in the rule's action buffer structure.
bool isVerifyR266 = BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0) == 2;
Site.CaptureRequirementIfIsTrue(
isVerifyR266,
266,
@"[In ActionBlock Structure] The meaning of action type OP_TAG: Adds or changes a property on the message.");
#endregion
#region TestUser1 gets the rule action property to check the rule action property.
uint ruleHandle;
RopGetRulesTableResponse ruleTableResponse = new RopGetRulesTableResponse();
ruleHandle = this.OxoruleAdapter.RopGetRulesTable(this.InboxFolderHandle, TableFlags.Normal, out ruleTableResponse);
// Get rule property.
PropertyTag[] ruleProperty = new PropertyTag[1];
ruleProperty[0].PropertyId = (ushort)PropertyId.PidTagRuleActions;
ruleProperty[0].PropertyType = (ushort)PropertyType.PtypRuleAction;
RopQueryRowsResponse queryRowResponseOfProperty = this.OxoruleAdapter.QueryPropertiesInTable(ruleHandle, ruleProperty);
Site.Assert.AreEqual<uint>(0, queryRowResponseOfProperty.ReturnValue, "Getting the rule action property should succeed, the actual value is {0}!", queryRowResponseOfProperty.ReturnValue);
#endregion
}