public void MSOXORULE_S03_TC01_OOFBehaviorsNotExecuteSubRuleWithoutST_ONLY_WHEN_OOFForST_EXIT_LEVEL()
{
this.CheckMAPIHTTPTransportSupported();
#region Prepare value for ruleProperties variable.
RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameTag);
string setOOFMailAddress = this.User1Name + "@" + this.Domain;
string userPassword = this.User1Password;
#endregion
#region Set TestUser1 to OOF state.
bool isSetOOFSuccess = this.SUTSetOOFAdapter.SetUserOOFSettings(setOOFMailAddress, userPassword, true);
Site.Assert.IsTrue(isSetOOFSuccess, "Turn Out of Office on for {0} should succeed.", this.User1Name);
Thread.Sleep(this.WaitForSetOOFComplete);
#endregion
#region TestUser1 adds an OP_TAG rule with PidTagRuleState set to ST_ENABLED | ST_EXIT_LEVEL.
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 | RuleState.ST_EXIT_LEVEL, tagActionData, ruleProperties, null);
RopModifyRulesResponse ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleOpTag });
Site.Assert.AreEqual<uint>(0, ropModifyRulesResponse.ReturnValue, "Adding OP_TAG rule should succeed");
#endregion
#region TestUser1 adds OP_MARK_AS_READ rule with PidTagRuleState set to ST_ENABLED.
ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMarkAsRead);
RuleData ruleForMarkRead = AdapterHelper.GenerateValidRuleData(ActionType.OP_MARK_AS_READ, TestRuleDataType.ForAdd, 2, RuleState.ST_ENABLED, new DeleteMarkReadActionData(), ruleProperties, null);
ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_OnExisting, new RuleData[] { ruleForMarkRead });
Site.Assert.AreEqual<uint>(0, ropModifyRulesResponse.ReturnValue, "Adding mark as read rule should succeed.");
#endregion
#region TestUser2 delivers a message to TestUser1 to trigger these rules.
// Sleep enough time to wait for the rule to take effect.
Thread.Sleep(this.WaitForTheRuleToTakeEffect);
string mailSubject = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName);
this.SUTAdapter.SendMailToRecipient(this.User2Name, this.User2Password, this.User1Name, mailSubject);
// Sleep enough time to wait for the rule to be executed on the delivered message.
Thread.Sleep(this.WaitForTheRuleToTakeEffect);
#endregion
#region Testuser1 verifies whether the specific property value is set on the received mail.
PropertyTag[] propertyTagList = new PropertyTag[3];
propertyTagList[0].PropertyId = (ushort)PropertyId.PidTagImportance;
propertyTagList[0].PropertyType = (ushort)PropertyType.PtypInteger32;
propertyTagList[1].PropertyId = (ushort)PropertyId.PidTagSubject;
propertyTagList[1].PropertyType = (ushort)PropertyType.PtypString;
propertyTagList[2].PropertyId = (ushort)PropertyId.PidTagMessageFlags;
propertyTagList[2].PropertyType = (ushort)PropertyType.PtypInteger32;
uint contentsTableHandle = 0;
int expectedMessageIndex = 0;
RopQueryRowsResponse getMailMessageContent = this.GetExpectedMessage(this.InboxFolderHandle, ref contentsTableHandle, propertyTagList, ref expectedMessageIndex, mailSubject);
// If the PidTagImportance is the value 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.
Site.Assert.AreEqual<int>(2, BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0), "The value of PidTagImportance field should be the specific value set by the client.");
#endregion
#region Testuser1 verifies whether the received mail is marked as read.
bool isSubjectContainsRuleConditionSubject = false;
int messageFlags = 0;
mailSubject = AdapterHelper.PropertyValueConvertToString(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[1].Value);
if (mailSubject.Contains(ruleProperties.ConditionSubjectName))
{
isSubjectContainsRuleConditionSubject = true;
messageFlags = BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[2].Value, 0);
}
// Add the debug information.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R560, the value of markAsReadFlag is {0}", messageFlags);
// Verify MS-OXORULE requirement: MS-OXORULE_R560.
// 0x00000001 is the bit which indicates the message has been marked as read. So if this bit is not set in messageFlags,
// it means the message is not marked as read, which means the rule has not been executed.
bool isVerifyR560 = isSubjectContainsRuleConditionSubject && (messageFlags & 0x00000001) != 0x00000001;
Site.CaptureRequirementIfIsTrue(
isVerifyR560,
560,
@"[In Interaction Between ST_ONLY_WHEN_OOF and ST_EXIT_LEVEL Flags] When the Out of Office state is set on the mailbox, as specified in [MS-OXWOOF], and a rule (2) condition evaluates to ""TRUE"", if the rule (2) has the ST_EXIT_LEVEL flag specified in section 2.2.1.3.1.3 set, then the server MUST NOT evaluate subsequent rules (2) that do not have the ST_ONLY_WHEN_OOF flag set.");
#endregion
#region Set Testuser1 back to normal state (not in OOF state)
isSetOOFSuccess = this.SUTSetOOFAdapter.SetUserOOFSettings(setOOFMailAddress, userPassword, false);
Site.Assert.IsTrue(isSetOOFSuccess, "Turn Out of Office off for {0} should succeed.", this.User1Name);
Thread.Sleep(this.WaitForSetOOFComplete);
#endregion
}