public void MSOXORULE_S03_TC03_OOFBehaviorsForST_ONLY_WHEN_OOF()
{
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;
// Set the OOF status to false.
bool isSetOOFSuccess = this.SUTSetOOFAdapter.SetUserOOFSettings(setOOFMailAddress, userPassword, false);
Site.Assert.IsTrue(isSetOOFSuccess, "Turn Out of Office off for {0} should succeed.", this.User1Name);
#endregion
#region TestUser1 adds an OP_TAG rule with PidTagRuleState set to ST_ENABLED | ST_ONLY_WHEN_OOF.
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_ONLY_WHEN_OOF, 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 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, 1);
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[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 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.
bool isRuleNotExecuteWhenNotInOOFState = BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0) != 2;
Site.Assert.AreNotEqual<int>(2, BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0), "The value of PidTagImportance field should be the specific value set be the client.");
#endregion
#region Set TestUser1 to OOF state
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 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);
mailSubject = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName, 2);
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.
contentsTableHandle = 0;
expectedMessageIndex = 0;
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.
bool isRuleExecuteWhenInOOFState = BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0) == 2;
#region Capture Code
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R517: whether rule is executed or not when it is not in out of office state is {0}, and when it is in out of office state is {1}", isRuleNotExecuteWhenNotInOOFState, isRuleExecuteWhenInOOFState);
// Verify MS-OXORULE requirement: MS-OXORULE_R517.
bool isVerifyR517 = isRuleNotExecuteWhenNotInOOFState && isRuleExecuteWhenInOOFState;
Site.CaptureRequirementIfIsTrue(
isVerifyR517,
517,
@"[In Processing Incoming Messages to a Folder] The server MUST evaluate rules (2) that have the ST_ONLY_WHEN_OOF flag set in the PidTagRuleState property only when the mailbox is in an OOF state as specified in [MS-OXWOOF] section 2.2.4.1.");
// Add the debug information.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R553: whether rule is executed or not when it is not in out of office state is {0}, and when it is in out of office state is {1}", isRuleNotExecuteWhenNotInOOFState, isRuleExecuteWhenInOOFState);
// Verify MS-OXORULE requirement: MS-OXORULE_R553.
bool isVerifyR553 = isVerifyR517;
Site.CaptureRequirementIfIsTrue(
isVerifyR553,
553,
@"[In Processing Out of Office Rules] The server evaluates and executes Out of Office rules only when the mailbox is in an Out of Office state, as specified in [MS-OXWOOF] section 2.2.4.1.");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R582: whether rule is executed or not when it is not in out of office state is {0}, and when it is in out of office state is {1}", isRuleNotExecuteWhenNotInOOFState, isRuleExecuteWhenInOOFState);
// Verify MS-OXORULE requirement: MS-OXORULE_R582
bool isVerifyR582 = isVerifyR517;
Site.CaptureRequirementIfIsTrue(
isVerifyR582,
582,
@"[In Entering and Exiting the Out of Office State] When the mailbox enters the Out of Office state as specified in [MS-OXWOOF] section 2.2.4.1, the server MUST start processing rules (2) marked with the ST_ONLY_WHEN_OOF flag in the PidTagRuleState property (section 2.2.1.3.1.3).");
#endregion
#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
#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);
mailSubject = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName, 3);
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.
contentsTableHandle = 0;
expectedMessageIndex = 0;
getMailMessageContent = this.GetExpectedMessage(this.InboxFolderHandle, ref contentsTableHandle, propertyTagList, ref expectedMessageIndex, mailSubject);
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R584");
// Verify MS-OXORULE requirement: MS-OXORULE_R584
// 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.CaptureRequirementIfAreNotEqual<int>(
2,
BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[expectedMessageIndex].PropertyValues[0].Value, 0),
584,
@"[In Entering and Exiting the Out of Office State] When the mailbox exits the Out of Office state, the server MUST stop processing rules (2) marked with the ST_ONLY_WHEN_OOF flag in the PidTagRuleState property.");
#endregion
}