public void MSOXCFOLD_S03_TC03_RopSetSearchCriteriaSuccess()
{
this.CheckWhetherSupportTransport();
this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer);
this.GenericFolderInitialization();
#region Step 1. The client create a non-FAI message under the root folder.
ulong messageId = 0;
uint messageHandle = 0;
this.CreateSaveMessage(this.RootFolderHandle, this.RootFolderId, ref messageId, ref messageHandle);
#endregion
#region Step 2. The client calls RopCreateFolder to create a 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 = 0x02,
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 3. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder1].
ulong[] folderIds = new ulong[]
{
this.DefaultFolderIds[0]
};
RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest
{
RopId = (byte)RopId.RopSetSearchCriteria,
LogonId = Constants.CommonLogonId,
InputHandleIndex = Constants.CommonInputHandleIndex,
RestrictionDataSize = 0x0005
};
byte[] restrictionData = { 0x08, 0x1f, 0x00, 0x1a, 0x00 };
setSearchCriteriaRequest.RestrictionData = restrictionData;
setSearchCriteriaRequest.FolderIdCount = (ushort)folderIds.Length;
setSearchCriteriaRequest.FolderIds = folderIds;
setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.RestartSearch;
RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles);
Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSetSearchCriteria ROP operation performs successfully!");
// Add the debug information.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R512");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R512.
// Method SetSearchCriteria succeeds indicates that the server responds with a RopSetSearchCriteria ROP response buffer.
Site.CaptureRequirement(
512,
@"[In Processing a RopSetSearchCriteria ROP Request] The server responds with a RopSetSearchCriteria ROP response buffer.");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R98");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R98
Site.CaptureRequirementIfAreEqual<uint>(
Constants.SuccessCode,
setSearchCriteriaResponse.ReturnValue,
98,
@"[In RopSetSearchCriteria ROP] The RopSetSearchCriteria ROP ([MS-OXCROPS] section 2.2.4.4) establishes search criteria for a search folder.");
#region Verify the requirements: MS-OXCFOLD_R766, MS-OXCFOLD_R409, and MS-OXCFOLD_R47.
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R766");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R766
Site.CaptureRequirementIfAreEqual<uint>(
Constants.SuccessCode,
setSearchCriteriaResponse.ReturnValue,
766,
@"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): RESTART_SEARCH (0x00000002) means that the search is initiated, if this is the first RopSetSearchCriteria ROP request.");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R409");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R409
Site.CaptureRequirementIfAreEqual<uint>(
Constants.SuccessCode,
setSearchCriteriaResponse.ReturnValue,
409,
@"[In Setting Up a Search Folder] The client creates a search folder by using the RopCreateFolder ROP ([MS-OXCROPS] section 2.2.4.2) with the FolderType field set to the value 2, as specified in section 2.2.1.2.1.");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R47");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R47
Site.CaptureRequirementIfAreEqual<uint>(
Constants.SuccessCode,
setSearchCriteriaResponse.ReturnValue,
47,
@"[InRopCreateFolder ROP Request Buffer] FolderType (1 byte): The value 2 indicates the folder type is Search folder.");
#endregion
#endregion
#region Step 4. 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_R1200, MS-OXCFOLD_R772.
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1200");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1200
Site.CaptureRequirementIfAreEqual<ushort>(
(ushort)folderIds.Length,
getSearchCriteriaResponse.FolderIdCount,
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
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R772");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R772
Site.CaptureRequirementIfAreEqual<ushort>(
(ushort)folderIds.Length,
getSearchCriteriaResponse.FolderIdCount,
772,
@"[In RopSetSearchCriteria ROP Request Buffer] SearchFlags (4 bytes): SHALLOW_SEARCH (0x00000008) means that the search includes only the search folder containers that are specified in the FolderIds field.");
#endregion
#endregion
#region Step 5. The client calls RopSetSearchCriteria with no folder ID specified for search folder [MSOXCFOLDSearchFolder1] which is initialized in previous request.
setSearchCriteriaRequest = new RopSetSearchCriteriaRequest
{
RopId = (byte)RopId.RopSetSearchCriteria,
LogonId = Constants.CommonLogonId,
InputHandleIndex = Constants.CommonInputHandleIndex,
RestrictionData = restrictionData,
SearchFlags = (uint)SetSearchFlags.RestartSearch,
FolderIdCount = 0,
FolderIds = null
};
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 [MSOXCFOLDSearchFolder1].
getSearchCriteriaRequest = new RopGetSearchCriteriaRequest
{
RopId = (byte)RopId.RopGetSearchCriteria,
LogonId = Constants.CommonLogonId,
InputHandleIndex = Constants.CommonInputHandleIndex,
UseUnicode = 0x00,
IncludeRestriction = 0x01,
IncludeFolders = 0x01
};
RopGetSearchCriteriaResponse getSearchCriteriaResponseForNoFolderID = 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
this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1241");
// Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1241
this.Site.CaptureRequirementIfIsTrue(
this.CompareFolderIDs(getSearchCriteriaResponse.FolderIds, getSearchCriteriaResponseForNoFolderID.FolderIds),
1241,
@"[In Processing a RopSetSearchCriteria ROP Request] If the client does not specify FIDs in a subsequent RopSetSearchCriteria ROP request, the server uses the FIDs that were specified in the previous request.");
#endregion
}