public void MSOXORULE_S03_TC07_OOFBehaviorsForFlagDisableSpecificOOFRule()
{
this.CheckMAPIHTTPTransportSupported();
Site.Assume.IsTrue(Common.IsRequirementEnabled(624, this.Site), "This case runs only when implementation does use flag 0x00000080 to disable a specific Out of Office rule.");
#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 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");
// Call RopGetRulesTable with valid TableFlags.
RopGetRulesTableResponse ropGetRulesTableResponse;
uint ruleTableHandle = this.OxoruleAdapter.RopGetRulesTable(this.InboxFolderHandle, TableFlags.Normal, out ropGetRulesTableResponse);
Site.Assert.AreEqual<uint>(0, ropGetRulesTableResponse.ReturnValue, "Getting rule table should succeed.");
// Get rule properties.
PropertyTag[] propertyTags = new PropertyTag[2];
propertyTags[0].PropertyId = (ushort)PropertyId.PidTagRuleName;
propertyTags[0].PropertyType = (ushort)PropertyType.PtypString;
propertyTags[1].PropertyId = (ushort)PropertyId.PidTagRuleId;
propertyTags[1].PropertyType = (ushort)PropertyType.PtypInteger64;
RopQueryRowsResponse queryRowsResponse = this.OxoruleAdapter.QueryPropertiesInTable(ruleTableHandle, propertyTags);
Site.Assert.AreEqual<uint>(0, queryRowsResponse.ReturnValue, "Retrieving rows from the rule table should succeed.");
ulong ruleId = 0;
// Filter the correct rule.
for (int i = 0; i < queryRowsResponse.RowCount; i++)
{
string ruleName = AdapterHelper.PropertyValueConvertToString(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[0].Value);
if (ruleName == ruleProperties.Name)
{
ruleId = BitConverter.ToUInt64(queryRowsResponse.RowData.PropertyRows[i].PropertyValues[1].Value, 0);
break;
}
}
#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 TestUser2 delivers a message to TestUser1 to trigger these rules.
string messageSubjectName1 = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName, 1);
// Sleep enough time to wait for the rule to take effect.
Thread.Sleep(this.WaitForTheRuleToTakeEffect);
this.SUTAdapter.SendMailToRecipient(this.User2Name, this.User2Password, this.User1Name, messageSubjectName1);
// 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, messageSubjectName1);
// 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;
Site.Assert.IsTrue(isRuleExecuteWhenInOOFState, "The OP_TAG rule should be executed in OOF state!");
#endregion
#region Disable the OP_TAG rule.
ruleOpTag = AdapterHelper.GenerateValidRuleData(ActionType.OP_TAG, TestRuleDataType.ForModify, 1, RuleState.X_DisableSpecificOOFRule | RuleState.ST_ONLY_WHEN_OOF, tagActionData, ruleProperties, ruleId);
ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_OnExisting, new RuleData[] { ruleOpTag });
Site.Assert.AreEqual<uint>(0, ropModifyRulesResponse.ReturnValue, "Modifying the OP_TAG rule should succeed.");
#endregion
#region TestUser2 delivers a message to TestUser1 to trigger these rules.
string messageSubjectName2 = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName, 2);
// Sleep enough time to wait for the rule to take effect.
Thread.Sleep(this.WaitForTheRuleToTakeEffect);
this.SUTAdapter.SendMailToRecipient(this.User2Name, this.User2Password, this.User1Name, messageSubjectName2);
// 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, messageSubjectName2);
// 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.
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_R624");
// Verify MS-OXORULE requirement: MS-OXORULE_R624.
Site.CaptureRequirementIfIsFalse(
isRuleExecuteWhenInOOFState,
624,
@"[In Appendix A: Product Behavior] Bit flag 0x00000080 is used to disable a specific Out of Office rule on the implementation. [<1> Section 2.2.1.3.2.3: Bit flag 0x00000080 is used to disable a specific Out of Office rule on Exchange 2007.]");
if (Common.IsRequirementEnabled(621, this.Site))
{
// Add the debug information.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R621");
// Verify MS-OXORULE requirement: MS-OXORULE_R621.
// If r624 and r625 are completed, it means it does use the bit flags 0x00000080 and 0x00000100.
Site.CaptureRequirement(
621,
"[In Appendix A: Product Behavior] The implementation uses bit flags 0x00000080 and 0x00000100 to store information about Out of Office functionality. [<1> Section 2.2.1.3.1.3: The Exchange 2007 implementation uses bit flags 0x00000080 and 0x00000100 to store information about Out of Office functionality.]");
}
#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
}