public void MSOXORULE_S02_TC10_ServerExecuteRule_Action_OP_MOVE()
{
this.CheckMAPIHTTPTransportSupported();
Site.Assume.IsTrue(Common.IsRequirementEnabled(929, this.Site), "This case runs only when the server supports OP_MOVE action when FolderInThisStore is set to 0.");
#region Prepare value for ruleProperties variable.
RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameMoveOne);
#endregion
#region TestUser1 creates folder1 in server store.
RopCreateFolderResponse createFolderResponse;
uint newFolderHandle = this.OxoruleAdapter.RopCreateFolder(this.InboxFolderHandle, Common.GenerateResourceName(this.Site, "User1Folder01"), "TestForOP_MOVE", out createFolderResponse);
ulong newFolderId = createFolderResponse.FolderId;
Site.Assert.AreEqual<uint>(0, createFolderResponse.ReturnValue, "Creating folder operation should succeed.");
#endregion
#region Prepare rules' data
MoveCopyActionData moveCopyActionData1 = new MoveCopyActionData();
// Get the created folder1 entry id.
byte[] folder1EId = this.OxoruleAdapter.GetFolderEntryId(StoreObjectType.Mailbox, newFolderHandle, newFolderId);
// Get the store object's entry id
byte[] storeEId = this.GetStoreObjectEntryID(StoreObjectType.Mailbox, this.Server, this.User1ESSDN);
moveCopyActionData1.FolderInThisStore = 0;
moveCopyActionData1.FolderEID = folder1EId;
moveCopyActionData1.StoreEID = storeEId;
moveCopyActionData1.FolderEIDSize = (ushort)folder1EId.Length;
moveCopyActionData1.StoreEIDSize = (ushort)storeEId.Length;
IActionData[] moveCopyActionData = { moveCopyActionData1 };
#endregion
#region Generate test RuleData.
// Add rule for move without rule Provider Data.
ruleProperties.ProviderData = string.Empty;
RuleData ruleForMoveFolder = AdapterHelper.GenerateValidRuleDataWithFlavor(new ActionType[] { ActionType.OP_MOVE }, 0, RuleState.ST_ENABLED, moveCopyActionData, new uint[] { 0 }, ruleProperties);
#endregion
#region TestUser1 adds OP_MOVE rule to the Inbox folder.
RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForMoveFolder });
Site.Assert.AreEqual<uint>(0, modifyRulesResponse.ReturnValue, "Adding Move rule should succeed.");
#endregion
#region TestUser2 delivers a message to TestUser1 to trigger these rules.
// TestUser2 deliver a message to trigger these rules.
string mailSubject = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName + "Title");
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 content to verify the rule evaluation.
uint inboxFolderContentsTableHandle = 0;
PropertyTag[] propertyTagList = new PropertyTag[1];
propertyTagList[0].PropertyId = (ushort)PropertyId.PidTagSubject;
propertyTagList[0].PropertyType = (ushort)PropertyType.PtypString;
bool doesOriginalMessageExist = this.CheckUnexpectedMessageExist(this.InboxFolderHandle, ref inboxFolderContentsTableHandle, propertyTagList, mailSubject);
uint newFolder1ContentsTableHandle = 0;
uint rowCount = 0;
RopQueryRowsResponse getNewFolder1MailMessageContent = this.GetExpectedMessage(newFolderHandle, ref newFolder1ContentsTableHandle, propertyTagList, ref rowCount, 1, mailSubject);
Site.Assert.AreEqual<uint>(0, getNewFolder1MailMessageContent.ReturnValue, "Getting message on the folder should succeed.");
this.VerifyActionTypeOP_MOVE(getNewFolder1MailMessageContent, doesOriginalMessageExist);
// Add the debug information.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R929");
// Verify MS-OXORULE requirement: MS-OXORULE_R929.
// When the server moves the message to the destination store, it means StoreEID is set to the destination store EntryID.
bool isVerifyR929 = getNewFolder1MailMessageContent.RowCount == 1 && !doesOriginalMessageExist;
Site.CaptureRequirementIfIsTrue(
isVerifyR929,
929,
@"[In OP_MOVE and OP_COPY ActionData Structure] [Buffer Format for Standard Rules] StoreEID (variable): A Store Object EntryID structure, as specified in [MS-OXCDATA] section 2.2.4.3, [In OP_MOVE action data] Identifies the message store.");
#endregion
#region Delete the folders created in step2 and step3.
RopDeleteFolderResponse deleteFolder = this.OxoruleAdapter.RopDeleteFolder(this.InboxFolderHandle, newFolderId);
Site.Assert.AreEqual<uint>(0, deleteFolder.ReturnValue, "Deleting folder should succeed.");
#endregion
}