public void MSOXCFOLD_S03_TC02_DynamicSearchVerification() { this.CheckWhetherSupportTransport(); this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. The client calls RopCreateFolder to create the general folder [MSOXCFOLDSubfolder1] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest(); createFolderRequest.RopId = (byte)RopId.RopCreateFolder; createFolderRequest.LogonId = Constants.CommonLogonId; createFolderRequest.InputHandleIndex = Constants.CommonInputHandleIndex; createFolderRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex; createFolderRequest.FolderType = 0x01; createFolderRequest.UseUnicodeStrings = 0x0; createFolderRequest.OpenExisting = 0x00; createFolderRequest.Reserved = 0x0; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.Subfolder1); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.Subfolder1); RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint subfolderHandle1 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; ulong subfolderId1 = createFolderResponse.FolderId; #endregion #region Step 2. The client creates a non-FAI message under the general folder [MSOXCFOLDSubfolder1]. uint messageNonFAIHandle1 = 0; ulong messageNonFAIId1 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageNonFAIId1, ref messageNonFAIHandle1); #endregion #region Step 3. The client calls RopCreateFolder to create the search folder [MSOXCFOLDSearchFolder1] under the root folder. createFolderRequest.FolderType = 0x02; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder); createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 4. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder1]. RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; ExistRestriction existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.NonContentIndexedSearch | (uint)SetSearchFlags.RestartSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R783"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R783 Site.CaptureRequirementIfAreEqual<uint>( Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, 783, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): NON_CONTENT_INDEXED_SEARCH (0x00020000) means that the search does not use a content-indexed search."); #endregion #region Step 5. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. RopGetSearchCriteriaRequest getSearchCriteriaRequest = new RopGetSearchCriteriaRequest { RopId = (byte)RopId.RopGetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, UseUnicode = 0x00, IncludeRestriction = 0x01, IncludeFolders = 0x01 }; RopGetSearchCriteriaResponse getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R785"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R785 Site.CaptureRequirementIfAreEqual<uint>( (uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, 785, @"[In RopGetSearchCriteria ROP Response Buffer] SearchFlags (4 bytes): SEARCH_RUNNING (0x00000001) means that the search is running, which means that the initial population of the search folder still being compiled."); #endregion #region Step 6. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder1]. RopGetContentsTableRequest getContentsTableRequest = new RopGetContentsTableRequest(); RopGetContentsTableResponse getContentsTableResponse; getContentsTableRequest.RopId = (byte)RopId.RopGetContentsTable; getContentsTableRequest.LogonId = Constants.CommonLogonId; getContentsTableRequest.InputHandleIndex = Constants.CommonInputHandleIndex; getContentsTableRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex; getContentsTableRequest.TableFlags = (byte)FolderTableFlags.None; int count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 1) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); #region Verify the requirements: MS-OXCFOLD_R552, MS-OXCFOLD_R526. Site.Assert.AreEqual<uint>((uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, "The RopSearchCriteria ROP operation has not been complete."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R526"); // If the client has received the success code from the server after sending a RopSetSearchCriteria request. // If the client has received a 'SEARCH_RUNNING' SearchFlags in the RopGetSearchCriteria response after sending a RopGetSearchCriteria response later. // If the client has got the messages which according to the search criteria and search scope that are specified in the RopSetSearchCriteria ROP request in the RopGetContentsTable response after sending a RopGetContentsTable request later. // Satisfy the above conditions, then this requirement can be verified directly. Site.CaptureRequirement( 526, @"[In Processing a RopSetSearchCriteria ROP Request] The server can return the RopSetSearchCriteria ROP response before the search folder is fully updated."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R552"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R552 // There should have 1 message macthed the search criteria, so the RowCount should be 1. Site.CaptureRequirementIfAreEqual<uint>( 1, getContentsTableResponse.RowCount, 552, @"[In Processing a RopSetSearchCriteria ROP Request] A dynamic search causes the search folder to be initially populated with all messages that match the search criteria at the point in time when the search is started or restarted."); #endregion #endregion #region Step 7. The client calls RopSetSearchCriteria without setting the SearchFlags to establish search criteria for [MSOXCFOLDSearchFolder1]. setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.None; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 8. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); #endregion #region Step 9. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder1]. count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 1) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); #endregion #region Step 10. The client creates a non-FAI message under the general folder [MSOXCFOLDSubfolder1]. uint messageNonFAIHandle3 = 0; ulong messageNonFAIId3 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageNonFAIId3, ref messageNonFAIHandle3); #endregion #region Step 11. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder1]. count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 2) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); #region Verify the requirements: MS-OXCFOLD_R1095, MS-OXCFOLD_R1210, MS-OXCFOLD_R1096, and MS-OXCFOLD_R1097. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1096"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1096 // There should have 2 messages found so the RowCount should be 2. Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 1096, @"[In Processing a RopSetSearchCriteria ROP Request] For dynamic search folders, the contents of the search folder MUST continue to be updated as messages start to match or cease to match the search criteria. "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1210"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1210 Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 1210, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): STATIC_SEARCH (0x00040000) means that the search is dynamic, if not set."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1095"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1095 // There should have 2 messages found so the RowCount should be 2. Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 1095, @"[In Processing a RopSetSearchCriteria ROP Request] For dynamic search folders, the contents of the search folder MUST continue to be updated as messages move around the mailbox. "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1097"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1097 Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 1097, @"[In Processing a RopSetSearchCriteria ROP Request] The server continues to update the search folder with messages that enter or exit the search criteria."); #endregion #endregion }
public void MSOXCFOLD_S03_TC01_StaticSearchVerification() { this.CheckWhetherSupportTransport(); this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. The client calls RopCreateFolder to create the general folder [MSOXCFOLDSubfolder1] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = (byte)FolderType.Genericfolder, UseUnicodeStrings = 0x0, OpenExisting = 0x00, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.Subfolder1), Comment = Encoding.ASCII.GetBytes(Constants.Subfolder1) }; RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint subfolderHandle1 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; ulong subfolderId1 = createFolderResponse.FolderId; #endregion #region Step 2. The client creates two general messages under the folder [MSOXCFOLDSubfolder1]. uint messageHandle1 = 0; ulong messageId1 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageId1, ref messageHandle1); uint messageHandle2 = 0; ulong messageId2 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageId2, ref messageHandle2); #endregion #region Step 3. The client calls RopCreateFolder to create the search folder [MSOXCFOLDSearchFolder2] under the root folder. createFolderRequest.FolderType = (byte)FolderType.Searchfolder; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder2); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder2); createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle2 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 4. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder2]. RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; ExistRestriction existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.ContentIndexedSearch | (uint)SetSearchFlags.StaticSearch | (uint)SetSearchFlags.RestartSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 5. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder2]. RopGetSearchCriteriaRequest getSearchCriteriaRequest = new RopGetSearchCriteriaRequest { RopId = (byte)RopId.RopGetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, UseUnicode = 0x00, IncludeRestriction = 0x01, IncludeFolders = 0x01 }; RopGetSearchCriteriaResponse getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); #region Verify the requirements: MS-OXCFOLD_R1200 and MS-OXCFOLD_R1233. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1200"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1200 // SHALLOW_SEARCH bit in the RopSetSearchCriteria ROP request means the search includes only the search folder containers that are specified in the FolderIds field. // If the bit SEARCH_RECURSIVE in the RopGetSearchCriteria ROP response is not set means only the search folder containers that are specified in the last RopSetSearchCriteria ROP request are being searched. // So, if the bit SEARCH_RECURSIVE in getSearchCriteriaResponse is not set, R1200 can be verified. Site.CaptureRequirementIfAreNotEqual<uint>( (uint)GetSearchFlags.Recursive, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Recursive, 1200, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): If neither bit [RECURSIVE_SEARCH or SHALLOW_SEARCH] is set, the default is SHALLOW_SEARCH."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1233"); List<ulong> folderIdsInGetSearchCriteriaResponse = new List<ulong>(); folderIdsInGetSearchCriteriaResponse.AddRange(getSearchCriteriaResponse.FolderIds); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1233 this.Site.CaptureRequirementIfIsFalse( folderIdsInGetSearchCriteriaResponse.Contains(createFolderResponse.FolderId), 1233, @"[In Setting Up a Search Folder] [A search folder cannot be included in its own search scope] Therefore, the FolderIds field MUST NOT include the FID of the search folder."); #endregion #endregion #region Step 6. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder2]. RopGetContentsTableRequest getContentsTableRequest = new RopGetContentsTableRequest(); RopGetContentsTableResponse getContentsTableResponse; getContentsTableRequest.RopId = (byte)RopId.RopGetContentsTable; getContentsTableRequest.LogonId = Constants.CommonLogonId; getContentsTableRequest.InputHandleIndex = Constants.CommonInputHandleIndex; getContentsTableRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex; getContentsTableRequest.TableFlags = (byte)FolderTableFlags.None; int count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 2) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); uint rowCountBeforeHardDel = getContentsTableResponse.RowCount; Site.Assert.AreEqual<uint>(2, rowCountBeforeHardDel, "The two general messages created in step 2 were fetched in search folder."); #endregion #region Step 7. The client calls RopHardDeleteMessage ROP operation to hard delete a message in the general folder [MSOXCFOLDSubfolder1] under the root folder. ulong[] messageIds = new ulong[] { messageId1 }; RopHardDeleteMessagesRequest hardDeleteMessagesRequest = new RopHardDeleteMessagesRequest { RopId = (byte)RopId.RopHardDeleteMessages, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, WantAsynchronous = 0x00, NotifyNonRead = 0x00, MessageIdCount = (ushort)messageIds.Length, MessageIds = messageIds }; RopHardDeleteMessagesResponse hardDeleteMessagesResponse = this.Adapter.HardDeleteMessages(hardDeleteMessagesRequest, subfolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, hardDeleteMessagesResponse.ReturnValue, "RopHardDeleteMessages ROP operation performs successfully!"); Site.Assert.AreEqual<uint>(0x00, hardDeleteMessagesResponse.PartialCompletion, "RopHardDeleteMessages ROP operation is complete!"); #endregion #region Step 8. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder2]. count = 0; bool searchFolderNotChange = false; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != rowCountBeforeHardDel) { Thread.Sleep(this.WaitTime); } else { searchFolderNotChange = true; break; } count++; } while (count < this.RetryCount); #region Verify the requirements: MS-OXCFOLD_R795, MS-OXCFOLD_R784, MS-OXCFOLD_R1084, MS-OXCFOLD_R549, MS-OXCFOLD_R1093, MS-OXCFOLD_R1094. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R795"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R795 // The search folder contents didn't change after the message has been hard deleted, it indicates the current search is static search. Site.CaptureRequirementIfIsTrue( searchFolderNotChange, 795, @"[In RopGetSearchCriteria ROP Response Buffer] SearchFlags (4 bytes): SEARCH_STATIC (0x00010000) means that the search is static."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R784"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R784 Site.CaptureRequirementIfIsTrue( searchFolderNotChange, 784, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): STATIC_SEARCH (0x00040000) means that the search is static, if set."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1084"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1084 Site.CaptureRequirementIfIsTrue( searchFolderNotChange, 1084, @"[In Processing a RopSetSearchCriteria ROP Request] For static search folders, the contents of the search folder are not updated after the initial population is complete."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R549"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R549 Site.CaptureRequirementIfIsTrue( searchFolderNotChange, 549, @"[In Processing a RopSetSearchCriteria ROP Request] A static search causes the search folder to be populated once with all messages that match the search criteria at the point in time when the search is started or restarted."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1093"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1093 Site.CaptureRequirementIfIsTrue( searchFolderNotChange, 1093, @"[In Processing a RopSetSearchCriteria ROP Request] The server MUST NOT update the search folder after the initial population when new messages that match the search criteria arrive in the search scope."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1094"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1094 Site.CaptureRequirementIfIsTrue( searchFolderNotChange, 1094, @"[In Processing a RopSetSearchCriteria ROP Request] Or the server MUST NOT update the search folder after the initial population when existing messages that fit the search criteria are deleted."); #endregion #endregion #region Step 9. The client calls RopSetSearchCriteria to restart the search for [MSOXCFOLDSearchFolder2]. setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.ContentIndexedSearch | (uint)SetSearchFlags.RestartSearch; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 10. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder2]. count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 1) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R551"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R551 // There should be 1 message found and copy to the search folder, so the RowCount should be 1. Site.CaptureRequirementIfAreEqual<uint>( 1, getContentsTableResponse.RowCount, 551, @"[In Processing a RopSetSearchCriteria ROP Request] To trigger an update, another RopSetSearchCriteria ROP request with the RESTART_SEARCH bit set in the SearchFlags field, as specified in section 2.2.1.4.1, is required."); #endregion #region Step 11. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder2] by a new RestrictionData. setSearchCriteriaRequest = new RopSetSearchCriteriaRequest(); setSearchCriteriaRequest.RopId = (byte)RopId.RopSetSearchCriteria; setSearchCriteriaRequest.LogonId = Constants.CommonLogonId; setSearchCriteriaRequest.InputHandleIndex = Constants.CommonInputHandleIndex; ContentRestriction contentRestriction = new ContentRestriction { FuzzyLevelLow = FuzzyLevelLowValues.FL_PREFIX, FuzzyLevelHigh = FuzzyLevelHighValues.FL_IGNORECASE }; propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; contentRestriction.PropertyTag = propertyTag; TaggedPropertyValue taggedProperty = new TaggedPropertyValue { PropertyTag = propertyTag, Value = Encoding.Unicode.GetBytes("IPM.Task" + Constants.StringNullTerminated) }; contentRestriction.TaggedValue = taggedProperty; setSearchCriteriaRequest.RestrictionDataSize = (ushort)contentRestriction.Size(); setSearchCriteriaRequest.RestrictionData = contentRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.ContentIndexedSearch | (uint)SetSearchFlags.RestartSearch | (uint)SetSearchFlags.StaticSearch; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 12. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder2]. count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 0) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R519"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R519 // For no message should be found so the search folder should empty, which means the RowCount is 0. Site.CaptureRequirementIfAreEqual<uint>( 0, getContentsTableResponse.RowCount, 519, @"[In Processing a RopSetSearchCriteria ROP Request] When new search criteria are applied, the server modifies the search folder to include only the messages that match the new search criteria."); #endregion }
public void MSOXCFOLD_S03_TC17_RopSetSearchCriteriaRegardlessOfSTATIC_SEARCH() { this.CheckWhetherSupportTransport(); this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. The client calls RopCreateFolder to create the general folder [MSOXCFOLDSubfolder1] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = (byte)FolderType.Genericfolder, UseUnicodeStrings = 0x0, OpenExisting = 0x00, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.Subfolder1), Comment = Encoding.ASCII.GetBytes(Constants.Subfolder1) }; RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint subfolderHandle1 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; ulong subfolderId1 = createFolderResponse.FolderId; #endregion #region Step 2. The client creates two general messages under the folder [MSOXCFOLDSubfolder1]. uint messageHandle1 = 0; ulong messageId1 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageId1, ref messageHandle1); uint messageHandle2 = 0; ulong messageId2 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageId2, ref messageHandle2); #endregion #region Step 3. The client calls RopCreateFolder to create the search folder [MSOXCFOLDSearchFolder2] under the root folder. createFolderRequest.FolderType = (byte)FolderType.Searchfolder; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder2); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder2); createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle2 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 4. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder2] without setting STATIC_SEARCH bit. RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; ExistRestriction existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.ContentIndexedSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 5. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder2]. RopGetSearchCriteriaRequest getSearchCriteriaRequest = new RopGetSearchCriteriaRequest { RopId = (byte)RopId.RopGetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, UseUnicode = 0x00, IncludeRestriction = 0x01, IncludeFolders = 0x01 }; RopGetSearchCriteriaResponse getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); if (Common.IsRequirementEnabled(1238001, this.Site)) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1238001"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1238001 Site.CaptureRequirementIfAreEqual<uint>( (uint)GetSearchFlags.Static, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Static, 1238001, @"[In Appendix A: Product Behavior] Implementation does be regardless of the value of the STATIC_SEARCH bit in the RopSetSearchCriteria ROP request. <14> Section 3.2.5.4: A content-indexed search is always static on the initial release version of Exchange 2010 and Exchange 2007 regardless of the value of the STATIC_SEARCH bit in the RopSetSearchCriteria request."); } if (Common.IsRequirementEnabled(1238002, this.Site)) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1238002"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1238002 Site.CaptureRequirementIfAreNotEqual<uint>( (uint)GetSearchFlags.Static, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Static, 1238002, @"[In Appendix A: Product Behavior] Implementation does not be regardless of the value of the STATIC_SEARCH bit in the RopSetSearchCriteria ROP request.(Exchange 2013 and above follow this hebavior)."); } #endregion }
public void MSOXCFOLD_S03_TC16_GetPropertyPidTagFolderFlags() { this.CheckWhetherSupportTransport(); this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. Call RopCreateFolder to create [MSOXCFOLDSubfolder1] under the root folder. uint subfolderHandle1 = 0; ulong subfolderId1 = 0; this.CreateFolder(this.RootFolderHandle, Constants.Subfolder1, ref subfolderId1, ref subfolderHandle1); #endregion #region Step 2. Creates a none-FAI message in [MSOXCFOLDSubfolder1]. ulong messageId = 0; uint messageHandle = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageId, ref messageHandle); #endregion #region Step 3. Create a FAI message and saves it in [MSOXCFOLDSubfolder1]. uint messageHandle2 = 0; ulong messageId2 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, 0x01, ref messageId2, ref messageHandle2); #endregion #region Step 4. The client calls RopCreateFolder to create the search folder [MSOXCFOLDSearchFolder1] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = (byte)FolderType.Searchfolder, UseUnicodeStrings = 0x0, OpenExisting = 0x00, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder), Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder) }; RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 5. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder1]. RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; ExistRestriction existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.NonContentIndexedSearch | (uint)SetSearchFlags.RestartSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 6. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder1]. RopGetContentsTableRequest getContentsTableRequest = new RopGetContentsTableRequest(); RopGetContentsTableResponse getContentsTableResponse; getContentsTableRequest.RopId = (byte)RopId.RopGetContentsTable; getContentsTableRequest.LogonId = Constants.CommonLogonId; getContentsTableRequest.InputHandleIndex = Constants.CommonInputHandleIndex; getContentsTableRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex; getContentsTableRequest.TableFlags = (byte)FolderTableFlags.None; int count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 1) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); #endregion #region Step 7. The client creates rules on [MSOXCFOLDSubfolder1] folder. RuleData[] sampleRuleDataArray; object ropResponse = null; sampleRuleDataArray = this.CreateSampleRuleDataArrayForAdd(); RopModifyRulesRequest modifyRulesRequest = new RopModifyRulesRequest() { RopId = (byte)RopId.RopModifyRules, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, ModifyRulesFlags = 0x00, RulesCount = (ushort)sampleRuleDataArray.Length, RulesData = sampleRuleDataArray, }; modifyRulesRequest.RopId = (byte)RopId.RopModifyRules; modifyRulesRequest.LogonId = Constants.CommonLogonId; modifyRulesRequest.InputHandleIndex = Constants.CommonInputHandleIndex; sampleRuleDataArray = this.CreateSampleRuleDataArrayForAdd(); modifyRulesRequest.ModifyRulesFlags = 0x00; modifyRulesRequest.RulesCount = (ushort)sampleRuleDataArray.Length; modifyRulesRequest.RulesData = sampleRuleDataArray; this.Adapter.DoRopCall(modifyRulesRequest, subfolderHandle1, ref ropResponse, ref this.responseHandles); RopModifyRulesResponse modifyRulesResponse = (RopModifyRulesResponse)ropResponse; Site.Assert.AreEqual<uint>(Constants.SuccessCode, modifyRulesResponse.ReturnValue, "RopModifyRules ROP operation performs successfully!"); #endregion #region Step 8. The client calls RopOpenFolder to open [MSOXCFOLDSubfolder1] folder. RopOpenFolderRequest openFolderRequest = new RopOpenFolderRequest { RopId = (byte)RopId.RopOpenFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderId = subfolderId1, OpenModeFlags = (byte)FolderOpenModeFlags.None }; RopOpenFolderResponse openFolderResponse = this.Adapter.OpenFolder(openFolderRequest, subfolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, openFolderResponse.ReturnValue, "RopOpenFolder ROP operation performs successfully!"); #endregion #region Step 9. The client gets the PidTagFolderFlags propertie from [MSOXCFOLDSubfolder1]. PropertyTag[] propertyTagArray = new PropertyTag[1]; propertyTag = new PropertyTag { PropertyId = (ushort)FolderPropertyId.PidTagFolderFlags, PropertyType = (ushort)PropertyType.PtypInteger32 }; propertyTagArray[0] = propertyTag; RopGetPropertiesSpecificRequest getPropertiesSpecificRequest = new RopGetPropertiesSpecificRequest(); RopGetPropertiesSpecificResponse getPropertiesSpecificResponse; getPropertiesSpecificRequest.RopId = (byte)RopId.RopGetPropertiesSpecific; getPropertiesSpecificRequest.LogonId = Constants.CommonLogonId; getPropertiesSpecificRequest.InputHandleIndex = Constants.CommonInputHandleIndex; getPropertiesSpecificRequest.PropertySizeLimit = 0xFFFF; getPropertiesSpecificRequest.PropertyTagCount = (ushort)propertyTagArray.Length; getPropertiesSpecificRequest.PropertyTags = propertyTagArray; getPropertiesSpecificResponse = this.Adapter.GetFolderObjectSpecificProperties(getPropertiesSpecificRequest, subfolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(0, getPropertiesSpecificResponse.ReturnValue, "RopGetPropertiesSpecific ROP operation performs successfully!"); uint pidTagFolderFlags = BitConverter.ToUInt32(getPropertiesSpecificResponse.RowData.PropertyValues[0].Value, 0); #region Verify MS-OXCFOLD_R1035110, MS-OXCFOLD_R1035111, MS-OXCFOLD_R1035103 and MS-OXCFOLD_R1035107 // Add the debug information Site.Log.Add(LogEntryKind.Debug, @"Verify MS-OXCFOLD_R1035110: [In PidTagFolderFlags Property] The PidTagFolderId property ([MS-OXPROPS] section 2.692) contains a computed value that specifies the type or state of a folder."); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1035110 Site.CaptureRequirement( 1035110, @"[In PidTagFolderFlags Property] The PidTagFolderId property ([MS-OXPROPS] section 2.692) contains a computed value that specifies the type or state of a folder."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, @"Verify MS-OXCFOLD_R1035111: [In PidTagFolderFlags Property] The value is a bitwise OR of zero or more values [1: IPM, 2: SEARCH, 4: NORMAL, 8: RULES] from the following table."); bool isR1035111Verified = false; if (((pidTagFolderFlags & 1) == 1) || ((pidTagFolderFlags & 2) == 2) || ((pidTagFolderFlags & 4) == 4) || ((pidTagFolderFlags & 8) == 8)) { isR1035111Verified = true; } // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1035111 Site.CaptureRequirementIfIsTrue( isR1035111Verified, 1035111, @"[In PidTagFolderFlags Property] The value is a bitwise OR of zero or more values [1: IPM, 2: SEARCH, 4: NORMAL, 8: RULES] from the following table."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, @"Verify MS-OXCFOLD_R1035103: [In PidTagFolderFlags Property] [The folder flag named ""IPM"" specified] the folder belongs to the IPM subtree portion of the mailbox."); bool isR1035103Verified = false; if ((pidTagFolderFlags & 1) == 1) { isR1035103Verified = true; } // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1035103 Site.CaptureRequirementIfIsTrue( isR1035103Verified, 1035103, @"[In PidTagFolderFlags Property] [The folder flag named ""IPM"" specified] the folder belongs to the IPM subtree portion of the mailbox."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, @"Verify MS-OXCFOLD_R1035107: [In PidTagFolderFlags Property] [The folder flag named ""NORMAL"" specified] the folder is a generic folder that contains messages and other folders."); bool isR1035107Verified = false; if ((pidTagFolderFlags & 4) == 4) { isR1035107Verified = true; } // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1035107 Site.CaptureRequirementIfIsTrue( isR1035107Verified, 1035107, @"[In PidTagFolderFlags Property] [The folder flag named ""NORMAL"" specified] the folder is a generic folder that contains messages and other folders."); #endregion #endregion }
public void MSOXCFOLD_S03_TC15_NonContentIndexedSearchVerification() { this.CheckWhetherSupportTransport(); this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. The client calls RopCreateFolder to create the general folder [MSOXCFOLDSubfolder1] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = 0x01, UseUnicodeStrings = 0x0, OpenExisting = 0x00, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.Subfolder1), Comment = Encoding.ASCII.GetBytes(Constants.Subfolder1) }; RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint subfolderHandle1 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; ulong subfolderId1 = createFolderResponse.FolderId; #endregion #region Step 2. The client creates a non-FAI message under the general folder [MSOXCFOLDSubfolder1]. uint messageNonFAIHandle1 = 0; ulong messageNonFAIId1 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageNonFAIId1, ref messageNonFAIHandle1); #endregion #region Step 3. The client calls RopCreateFolder to create the search folder [MSOXCFOLDSearchFolder1] under the root folder. createFolderRequest.FolderType = (byte)FolderType.Searchfolder; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder); createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 4. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder1]. RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; ExistRestriction existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.NonContentIndexedSearch | (uint)SetSearchFlags.RestartSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R783"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R783 Site.CaptureRequirementIfAreEqual<uint>( Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, 783, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): NON_CONTENT_INDEXED_SEARCH (0x00020000) means that the search does not use a content-indexed search."); #endregion #region Step 5. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder1]. RopGetContentsTableRequest getContentsTableRequest = new RopGetContentsTableRequest(); RopGetContentsTableResponse getContentsTableResponse; getContentsTableRequest.RopId = (byte)RopId.RopGetContentsTable; getContentsTableRequest.LogonId = Constants.CommonLogonId; getContentsTableRequest.InputHandleIndex = Constants.CommonInputHandleIndex; getContentsTableRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex; getContentsTableRequest.TableFlags = (byte)FolderTableFlags.None; int count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 1) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); #endregion #region Step 6. The client calls RopSetSearchCriteria to stop establish search criteria for [MSOXCFOLDSearchFolder1]. setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.StopSearch; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 7. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. RopGetSearchCriteriaRequest getSearchCriteriaRequest = new RopGetSearchCriteriaRequest { RopId = (byte)RopId.RopGetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, UseUnicode = 0x00, IncludeRestriction = 0x01, IncludeFolders = 0x01 }; RopGetSearchCriteriaResponse getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); #region Verify the requirements: MS-OXCFOLD_R673, MS-OXCFOLD_R54301. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R673"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R673 Site.CaptureRequirementIfAreNotEqual<uint>( (uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, 673, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes):STOP_SEARCH (0x00000001) means that the search is aborted."); if (Common.IsRequirementEnabled(54301, this.Site)) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R54301"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R54301 Site.CaptureRequirementIfAreNotEqual<uint>( (uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, 54301, @"[In Processing a RopSetSearchCriteria ROP Request] Implementation does stop the initial population of the search folder if the STOP_SEARCH bit is set in the SearchFlags field. (Exchange 2007 and above follow this behavior)."); } #endregion #endregion #region Step 8. The client calls RopSetSearchCriteria to restart establish search criteria for [MSOXCFOLDSearchFolder1]. setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.RestartSearch; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 9. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); Site.Assert.AreEqual<uint>((uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, "The SearchFlags field contains the 'SEARCH_RUNNING' bits."); #region Verify the requirements: MS-OXCFOLD_R546, MS-OXCFOLD_R768, and MS-OXCFOLD_R767. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R767"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R767 Site.CaptureRequirementIfAreEqual<uint>( (uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, 767, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): RESTART_SEARCH (0x00000002) means that the search is initiated, if the search is restarted."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R768"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R768 Site.CaptureRequirementIfAreEqual<uint>( (uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, 768, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): RESTART_SEARCH (0x00000002) means that the search is initiated, if the search is inactive."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R546"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R546 Site.CaptureRequirementIfAreEqual<uint>( (uint)GetSearchFlags.Running, getSearchCriteriaResponse.SearchFlags & (uint)GetSearchFlags.Running, 546, @"[In Processing a RopSetSearchCriteria ROP Request] If the RESTART_SEARCH bit is set in the SearchFlags field, the server restarts the population of the search folder."); #endregion #endregion }
public void MSOXCFOLD_S03_TC14_ContentIndexedSearchVerification() { this.CheckWhetherSupportTransport(); this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. The client calls RopCreateFolder to create the general folder [MSOXCFOLDSubfolder1] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = (byte)FolderType.Genericfolder, UseUnicodeStrings = 0x0, OpenExisting = 0x00, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.Subfolder1), Comment = Encoding.ASCII.GetBytes(Constants.Subfolder1) }; RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint subfolderHandle1 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; ulong subfolderId1 = createFolderResponse.FolderId; #endregion #region Step 2. The client creates a non-FAI message under the general folder [MSOXCFOLDSubfolder1]. uint messageNonFAIHandle1 = 0; ulong messageNonFAIId1 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageNonFAIId1, ref messageNonFAIHandle1); #endregion #region Step 3. The client calls RopCreateFolder to create the general folder [MSOXCFOLDSubfolder2] under the general folder [MSOXCFOLDSubfolder1]. createFolderRequest.FolderType = (byte)FolderType.Genericfolder; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.Subfolder2); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.Subfolder2); createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, subfolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint subfolderHandle2 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; ulong subfolderId2 = createFolderResponse.FolderId; #endregion #region Step 4. The client creates a non-FAI message under the general folder [MSOXCFOLDSubfolder2]. uint messageNonFAIHandle2 = 0; ulong messageNonFAIId2 = 0; this.CreateSaveMessage(subfolderHandle2, subfolderId2, ref messageNonFAIId2, ref messageNonFAIHandle2); #endregion #region Step 5. The client calls RopCreateFolder to create the search folder [MSOXCFOLDSearchFolder1] under the root folder. createFolderRequest.FolderType = (byte)FolderType.Searchfolder; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder); createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle1 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 6. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder1]. RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; ExistRestriction existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.ContentIndexedSearch | (uint)SetSearchFlags.RestartSearch | (uint)SetSearchFlags.ForGroundSearch | (uint)SetSearchFlags.RecursiveSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R782"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R782 Site.CaptureRequirementIfAreEqual<uint>( Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, 782, @"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): CONTENT_INDEXED_SEARCH (0x00010000) means that the search uses a content-indexed search."); #endregion #region Step 7. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. RopGetSearchCriteriaRequest getSearchCriteriaRequest = new RopGetSearchCriteriaRequest { RopId = (byte)RopId.RopGetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, UseUnicode = 0x00, IncludeRestriction = 0x01, IncludeFolders = 0x01 }; RopGetSearchCriteriaResponse getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); ulong priviewFolderId = getSearchCriteriaResponse.FolderIds[0]; #endregion #region Step 8. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder1]. RopGetContentsTableRequest getContentsTableRequest = new RopGetContentsTableRequest(); RopGetContentsTableResponse getContentsTableResponse; getContentsTableRequest.RopId = (byte)RopId.RopGetContentsTable; getContentsTableRequest.LogonId = Constants.CommonLogonId; getContentsTableRequest.InputHandleIndex = Constants.CommonInputHandleIndex; getContentsTableRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex; getContentsTableRequest.TableFlags = (byte)FolderTableFlags.None; int count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 2) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); #region Verify the requirements: MS-OXCFOLD_R515, MS-OXCFOLD_R770, and MS-OXCFOLD_R789. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R515"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R515 // There has 2 messages matched the search criteria, so the RowCount should be 2. Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 515, @"[In Processing a RopSetSearchCriteria ROP Request] The server fills the search folder according to the search criteria and search scope that are specified in the RopSetSearchCriteria ROP request."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R770"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R770 Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 770, @"[In RopSetSearchCriteria ROP Request Buffer]SearchFlags (4 bytes): RECURSIVE_SEARCH (0x00000004) means that the search includes the search folder containers and all of their child folders."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R789"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R789 // There has 2 messages matched search criteria, so the RowCount should be 2. Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 789, @"[In RopGetSearchCriteria ROP Response Buffer] SearchFlags (4 bytes): If this bit [SEARCH_RECURSIVE (0x00000004)] is set, the specified search folder containers and all their child search folder containers are searched for matching entries."); #endregion #endregion #region Step 9. The client creates a non-FAI message under the general folder [MSOXCFOLDSubfolder1]. uint messageNonFAIHandle3 = 0; ulong messageNonFAIId3 = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageNonFAIId3, ref messageNonFAIHandle3); #endregion #region Step 10. The client calls RopSetSearchCriteria without setting the SearchFlags field to establish search criteria for [MSOXCFOLDSearchFolder1]. setSearchCriteriaRequest.FolderIdCount = 0; setSearchCriteriaRequest.FolderIds = null; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.None; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 11. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle1, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R109"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R109 Site.CaptureRequirementIfAreEqual<ulong>( priviewFolderId, getSearchCriteriaResponse.FolderIds[0], 109, @"[In RopSetSearchCriteria ROP Request Buffer] FolderIdCount (2 bytes): If the FolderIdCount field is set to zero, the folders that were used in the most recent search are used again."); #endregion #region Step 12. The client calls RopCreateFolder to create the search folder [MSOXCFOLDSearchFolder2] under the root folder. createFolderRequest.FolderType = (byte)FolderType.Searchfolder; createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder2); createFolderRequest.Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder2); createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle2 = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 13. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder2]. setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.ContentIndexedSearch | (uint)SetSearchFlags.RestartSearch; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 14. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder2]. getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); #endregion #region Step 15. The client calls RopGetContentsTable to retrieve the contents table for the search folder [MSOXCFOLDSearchFolder2]. count = 0; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle2, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); if (getContentsTableResponse.RowCount != 2) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R960"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R960 // There has 2 messages matched the search criteria, so the RowCount should be 2. Site.CaptureRequirementIfAreEqual<uint>( 2, getContentsTableResponse.RowCount, 960, @"[In RopGetSearchCriteria ROP Response Buffer] If this bit [SEARCH_RECURSIVE] is not set, only the search folder containers that are specified in the last RopSetSearchCriteria ROP request (section 2.2.1.4.1) are being searched."); #endregion }
public void MSOXCFOLD_S02_TC11_RopMoveCopyMessagesUseSearchFolderSuccess() { this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. Call RopCreateFolder to create [MSOXCFOLDSubfolder1] under the root folder. ulong subfolderId1 = 0; uint subfolderHandle1 = 0; this.CreateFolder(this.RootFolderHandle, Constants.Subfolder1, ref subfolderId1, ref subfolderHandle1); #endregion #region Step 2. Create a message in the [MSOXCFOLDSubfolder1] folder created in step 1. uint messageHandle = 0; ulong messageId = 0; this.CreateSaveMessage(subfolderHandle1, subfolderId1, ref messageId, ref messageHandle); #endregion #region Step 3. Call RopCreateFolder to create [MSOXCFOLDSubfolder2] under the root folder. ulong subfolderId2 = 0; uint subfolderHandle2 = 0; this.CreateFolder(this.RootFolderHandle, Constants.Subfolder2, ref subfolderId2, ref subfolderHandle2); #endregion #region Step 4. Create a message in the [MSOXCFOLDSubfolder2] folder created in step 3. uint messageHandleInSubFolder2 = 0; ulong messageIdInSubFolder2 = 0; this.CreateSaveMessage(subfolderHandle2, subfolderId2, ref messageIdInSubFolder2, ref messageHandleInSubFolder2); #endregion #region Step 4. Call RopCreateFolder to create a search folder [MSOXCFOLDSearchFolder] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = (byte)FolderType.Searchfolder, UseUnicodeStrings = 0x0, OpenExisting = 0x00, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder), Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder) }; RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 5. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSubFolder1]. RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest { RopId = (byte)RopId.RopSetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; ExistRestriction existRestriction = new ExistRestriction { PropTag = propertyTag }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)existRestriction.Size(); setSearchCriteriaRequest.RestrictionData = existRestriction.Serialize(); setSearchCriteriaRequest.FolderIds = new ulong[] { subfolderId1 }; setSearchCriteriaRequest.FolderIdCount = (ushort)setSearchCriteriaRequest.FolderIds.Length; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.ContentIndexedSearch | (uint)SetSearchFlags.StaticSearch | (uint)SetSearchFlags.RestartSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSearchCriteria ROP operation performs successfully!"); #endregion #region Step 6. The client calls RopGetSearchCriteria to obtain the search criteria and the status of the search folder [MSOXCFOLDSubFolder1]. RopGetSearchCriteriaRequest getSearchCriteriaRequest = new RopGetSearchCriteriaRequest { RopId = (byte)RopId.RopGetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, UseUnicode = 0x00, IncludeRestriction = 0x01, IncludeFolders = 0x01 }; RopGetSearchCriteriaResponse getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); #endregion #region Step 7. The client calls RopGetContentsTable to get handle of the contents table in the search folder [MSOXCFOLDSearchFolder]. RopGetContentsTableRequest getContentsTableRequest = new RopGetContentsTableRequest(); RopGetContentsTableResponse getContentsTableResponse; getContentsTableRequest.RopId = (byte)RopId.RopGetContentsTable; getContentsTableRequest.LogonId = Constants.CommonLogonId; getContentsTableRequest.InputHandleIndex = Constants.CommonInputHandleIndex; getContentsTableRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex; getContentsTableRequest.TableFlags = (byte)FolderTableFlags.None; int count = 0; uint tableHandle; do { getContentsTableResponse = this.Adapter.GetContentsTable(getContentsTableRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getContentsTableResponse.ReturnValue, "RopGetContentsTable ROP operation performs successfully!"); tableHandle = this.responseHandles[0][getContentsTableResponse.OutputHandleIndex]; if (getContentsTableResponse.RowCount != 1) { Thread.Sleep(this.WaitTime); } else { break; } count++; } while (count < this.RetryCount); #endregion #region Step 8. Sets the properties PidTagMid visible on the content table. RopSetColumnsRequest setColumnsRequest; PropertyTag[] propertyTags = new PropertyTag[1]; propertyTags[0].PropertyId = (ushort)MessagePropertyId.PidTagMid; propertyTags[0].PropertyType = (ushort)PropertyType.PtypInteger64; setColumnsRequest.RopId = 0x12; setColumnsRequest.LogonId = 0x00; setColumnsRequest.InputHandleIndex = 0x00; setColumnsRequest.PropertyTagCount = (ushort)propertyTags.Length; setColumnsRequest.PropertyTags = propertyTags; setColumnsRequest.SetColumnsFlags = 0x00; // Sync object ropResponse = new object(); this.Adapter.DoRopCall(setColumnsRequest, tableHandle, ref ropResponse, ref this.responseHandles); #endregion #region Step 9. Gets the message ID in the search folder [MSOXCFOLDSearchFolder]. RopQueryRowsRequest queryRowsRequest; RopQueryRowsResponse queryRowsResponse; queryRowsRequest.RopId = 0x15; queryRowsRequest.LogonId = 0x00; queryRowsRequest.InputHandleIndex = 0x00; queryRowsRequest.QueryRowsFlags = 0x00; queryRowsRequest.ForwardRead = 0x01; queryRowsRequest.RowCount = 1; this.Adapter.DoRopCall(queryRowsRequest, tableHandle, ref ropResponse, ref this.responseHandles); queryRowsResponse = (RopQueryRowsResponse)ropResponse; ulong messageID = BitConverter.ToUInt64(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[0].Value, 0); #endregion #region Step 10. Call RopMoveCopyMessages to copy the message in the [MSOXCFOLDSearchFolder] to root folder synchronously. ulong[] messageIds = new ulong[1]; messageIds[0] = messageID; List<uint> handlelist = new List<uint> { searchFolderHandle, this.RootFolderHandle }; RopMoveCopyMessagesRequest moveCopyMessagesRequest = new RopMoveCopyMessagesRequest { RopId = (byte)RopId.RopMoveCopyMessages, LogonId = Constants.CommonLogonId, SourceHandleIndex = 0x00, DestHandleIndex = 0x01, MessageIdCount = (ushort)messageIds.Length, MessageIds = messageIds, WantAsynchronous = 0x00, WantCopy = 0xFF }; // WantCopy is nonzero (TRUE) indicates this is a copy operation. RopMoveCopyMessagesResponse copyMessagesFromSearchFolderResponse = this.Adapter.MoveCopyMessages(moveCopyMessagesRequest, handlelist, ref this.responseHandles); Site.Assert.AreEqual<uint>(0, copyMessagesFromSearchFolderResponse.ReturnValue, "The RopMoveCopyMessages ROP operation performs successfully."); Site.Assert.AreEqual<uint>(0, copyMessagesFromSearchFolderResponse.PartialCompletion, "The ROP successes for all subsets of targets"); handlelist.Clear(); #endregion #region Step 11. Validate the message is copied successfully in above step 9. uint rootFolderContentsCountActual = this.GetContentsTable(FolderTableFlags.None, this.RootFolderHandle); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R121702. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R121702: expected contents count of the root folder is {0}, actual contents count of the root folder is {1};", 1, rootFolderContentsCountActual); // The source folder is a search folder, so if the message was copied successfully from MSOXCFOLDSearchFolder to root folder, R121702 can be verified. Site.CaptureRequirementIfAreEqual<uint>( 1, rootFolderContentsCountActual, 121702, @"[In RopMoveCopyMessages ROP Request Buffer] SourceHandleIndex (1 byte): [The source Server object for this operation [RopMoveCopyMessages ROP] is a Folder object that represents the folder from which the messages will be copied] This folder can be a search folder."); #endregion #region Step 12. Call RopMoveCopyMessages to move the message in the [MSOXCFOLDSearchFolder] to root folder synchronously. messageIds = new ulong[1]; messageIds[0] = messageID; handlelist = new List<uint> { searchFolderHandle, this.RootFolderHandle }; moveCopyMessagesRequest = new RopMoveCopyMessagesRequest { RopId = (byte)RopId.RopMoveCopyMessages, LogonId = Constants.CommonLogonId, SourceHandleIndex = 0x00, DestHandleIndex = 0x01, MessageIdCount = (ushort)messageIds.Length, MessageIds = messageIds, WantAsynchronous = 0x00, WantCopy = 0x00 }; // WantCopy is zero (FALSE) indicates this is a move operation. RopMoveCopyMessagesResponse moveMessagesFromSearchFolderResponse = this.Adapter.MoveCopyMessages(moveCopyMessagesRequest, handlelist, ref this.responseHandles); Site.Assert.AreEqual<uint>(0, moveMessagesFromSearchFolderResponse.ReturnValue, "The RopMoveCopyMessages ROP operation performs successfully."); Site.Assert.AreEqual<uint>(0, moveMessagesFromSearchFolderResponse.PartialCompletion, "The ROP successes for all subsets of targets"); handlelist.Clear(); #endregion #region Step 13. Validate the message is moved successfully in above step 12. rootFolderContentsCountActual = this.GetContentsTable(FolderTableFlags.None, this.RootFolderHandle); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R121701. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R121701: expected contents count of the root folder is {0}, actual contents count of the root folder is {1};", 2, rootFolderContentsCountActual); // The source folder is a search folder, so if the message was moved successfully from MSOXCFOLDSearchFolder to root folder, R121701 can be verified. Site.CaptureRequirementIfAreEqual<uint>( 2, rootFolderContentsCountActual, 121701, @"[In RopMoveCopyMessages ROP Request Buffer] SourceHandleIndex (1 byte): [The source Server object for this operation [RopMoveCopyMessages ROP] is a Folder object that represents the folder from which the messages will be moved] This folder can be a search folder."); #endregion #region Step 14. Call RopMoveCopyMessages to copy the message in the [MSOXCFOLDSubfolder2] to the [MSOXCFOLDSearchFolder] synchronously. RopMoveCopyMessagesResponse copyMessagesToSearchFolderResponse = new RopMoveCopyMessagesResponse(); if (Common.IsRequirementEnabled(1246, this.Site)) { messageIds[0] = messageIdInSubFolder2; handlelist = new List<uint> { subfolderHandle2, searchFolderHandle }; moveCopyMessagesRequest = new RopMoveCopyMessagesRequest { RopId = (byte)RopId.RopMoveCopyMessages, LogonId = Constants.CommonLogonId, SourceHandleIndex = 0x00, DestHandleIndex = 0x01, MessageIdCount = (ushort)messageIds.Length, MessageIds = messageIds, WantAsynchronous = 0x00, WantCopy = 0xFF }; // WantCopy is nonzero (TRUE) indicates this is a copy operation. copyMessagesToSearchFolderResponse = this.Adapter.MoveCopyMessages(moveCopyMessagesRequest, handlelist, ref this.responseHandles); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R121802: the PartialCompletion in the MoveCopyMessages response is {0}", copyMessagesToSearchFolderResponse.PartialCompletion); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R121802 // If the ROP RopMoveCopyMessages fails to copy message, the value of PartialCompletion field is nonzero. this.Site.CaptureRequirementIfAreNotEqual<uint>( 0x00000000, copyMessagesToSearchFolderResponse.ReturnValue, 121802, @"[In RopMoveCopyMessages ROP Request Buffer] DestHandleIndex (1 byte): [The destination Server object for this operation [RopMoveCopyMessages ROP] is a Folder object that represents the folder to which the messages will be copied.] This folder cannot be a search folder."); } #endregion #region Step 15. Call RopMoveCopyMessages to move the message in the [MSOXCFOLDSubfolder2] to the [MSOXCFOLDSearchFolder] synchronously. RopMoveCopyMessagesResponse moveMessagesToSearchFolderResponse; if (Common.IsRequirementEnabled(1246, this.Site)) { messageIds[0] = messageIdInSubFolder2; handlelist = new List<uint> { subfolderHandle2, searchFolderHandle }; moveCopyMessagesRequest = new RopMoveCopyMessagesRequest { RopId = (byte)RopId.RopMoveCopyMessages, LogonId = Constants.CommonLogonId, SourceHandleIndex = 0x00, DestHandleIndex = 0x01, MessageIdCount = (ushort)messageIds.Length, MessageIds = messageIds, WantAsynchronous = 0x00, WantCopy = 0x00 }; // WantCopy is zero (FLASE) indicates this is a move operation. moveMessagesToSearchFolderResponse = this.Adapter.MoveCopyMessages(moveCopyMessagesRequest, handlelist, ref this.responseHandles); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R121801: the PartialCompletion in the MoveCopyMessages response is {0}", moveMessagesToSearchFolderResponse.PartialCompletion); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R121801 // If the ROP RopMoveCopyMessages fails to move message, the value of PartialCompletion field is nonzero. this.Site.CaptureRequirementIfAreNotEqual<uint>( 0x00000000, moveMessagesToSearchFolderResponse.ReturnValue, 121801, @"[In RopMoveCopyMessages ROP Request Buffer] DestHandleIndex (1 byte): [The destination Server object for this operation [RopMoveCopyMessages ROP] is a Folder object that represents the folder to which the messages will be moved.] This folder cannot be a search folder."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1216"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1216 bool isVerifiedR1216 = copyMessagesFromSearchFolderResponse.ReturnValue == 0x00000000 && moveMessagesFromSearchFolderResponse.ReturnValue == 0x00000000 && copyMessagesToSearchFolderResponse.ReturnValue != 0x00000000 && moveMessagesToSearchFolderResponse.ReturnValue != 0x00000000; this.Site.CaptureRequirementIfIsTrue( isVerifiedR1216, 1216, @"[In RopMoveCopyMessages ROP] The source folder can be a search folder, but the destination folder cannot."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1246: the return value is {0} when copy a message to a search folder and the return value is {1} when move a message to a search folder.", copyMessagesToSearchFolderResponse.ReturnValue, moveMessagesToSearchFolderResponse.ReturnValue); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1246 bool isVerifiedR1246 = copyMessagesToSearchFolderResponse.ReturnValue == 0x00000460 && moveMessagesToSearchFolderResponse.ReturnValue == 0x00000460; this.Site.CaptureRequirementIfIsTrue( isVerifiedR1246, 1246, @"[In Processing a RopMoveCopyMessages ROP Request] When the error code is ecSearchFolder, it indicates the destination object is a search folder. "); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1245"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1245 this.Site.CaptureRequirementIfAreEqual<uint>( 0x00000460, copyMessagesToSearchFolderResponse.ReturnValue, 1245, @"[In Processing a RopMoveCopyMessages ROP Request] The value of error code ecSearchFolder is 0x00000460."); } #endregion }