Microsoft.Protocols.TestSuites.MS_OXCFOLD.S03_FolderInformation.MSOXCFOLD_S03_TC11_RopSetSearchCriteriaFailure C# (CSharp) Method

MSOXCFOLD_S03_TC11_RopSetSearchCriteriaFailure() private method

private MSOXCFOLD_S03_TC11_RopSetSearchCriteriaFailure ( ) : void
return void
        public void MSOXCFOLD_S03_TC11_RopSetSearchCriteriaFailure()
        {
            this.CheckWhetherSupportTransport();
            this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer);
            this.GenericFolderInitialization();

            #region Step 1. The client calls RopSetSearchCriteria to establish search criteria for the root folder which is a generic folder rather a search folder.

            ulong[] folderIds = new ulong[]
                {
                    this.DefaultFolderIds[0],
                    this.DefaultFolderIds[1],
                    this.DefaultFolderIds[3],
                    this.DefaultFolderIds[4],
                    this.DefaultFolderIds[5],
                    this.DefaultFolderIds[6],
                    this.DefaultFolderIds[7],
                    this.DefaultFolderIds[8],
                    this.DefaultFolderIds[9],
                    this.DefaultFolderIds[10],
                    this.DefaultFolderIds[11],
                };

            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.StopSearch;
            RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, this.RootFolderHandle, ref this.responseHandles);

            #region Verify requirements: MS-OXCFOLD_R569, MS-OXCFOLD_R570, and MS-OXCFOLD_R46.

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R569");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R569
            Site.CaptureRequirementIfAreEqual<uint>(
                0x00000461,
                setSearchCriteriaResponse.ReturnValue,
                569,
                @"[In Processing a RopSetSearchCriteria ROP Request]The value of error code ecNotSearchFolder is 0x00000461.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R570");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R570
            Site.CaptureRequirementIfAreEqual<uint>(
                0x00000461,
                setSearchCriteriaResponse.ReturnValue,
                570,
                @"[In Processing a RopSetSearchCriteria ROP Request] When the error code is ecNotSearchFolder, it indicates the object is not a search folder.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R46");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R46
            Site.CaptureRequirementIfAreNotEqual<uint>(
                Constants.SuccessCode,
                setSearchCriteriaResponse.ReturnValue,
                46,
                @"[InRopCreateFolder ROP Request Buffer] FolderType (1 byte): The value 1 indicates the folder type is Generic folder.");

            #endregion

            #endregion

            #region Step 2. The client calls RopSetSearchCriteria with a logon object handle rather a search folder handle.

            // Use logon object handle in which case is purposed to get error code ecNotSupported [0x80040102].  
            setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, this.LogonHandle, ref this.responseHandles);

            #region Verify requirement: MS-OXCFOLD_R573, MS-OXCFOLD_R574.

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R573");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R573
            Site.CaptureRequirementIfAreEqual<uint>(
                0x80040102,
                setSearchCriteriaResponse.ReturnValue,
                573,
                @"[In Processing a RopSetSearchCriteria ROP Request]The value of error code ecNotSupported is 0x80040102.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R574");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R574
            Site.CaptureRequirementIfAreEqual<uint>(
                0x80040102,
                setSearchCriteriaResponse.ReturnValue,
                574,
                @"[In Processing a RopSetSearchCriteria ROP Request] When the error code is ecNotSupported, it indicates the object that this ROP [RopSetSearchCriteria] was called on is not a Folder object.");

            #endregion

            #endregion

            #region Step 3. The client calls RopCreateFolder to create a search folder named [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);
            uint searchFolderHandle = this.responseHandles[0][createFolderResponse.OutputHandleIndex];
            ulong searchFolderID = createFolderResponse.FolderId;
            #endregion

            #region Step 4. The client calls RopSetSearchCriteria use the handle of [MSOXCFOLDSearchFolder1] and a SearchFlags with invalid bit.

            setSearchCriteriaRequest = new RopSetSearchCriteriaRequest
            {
                RopId = (byte)RopId.RopSetSearchCriteria,
                LogonId = Constants.CommonLogonId,
                InputHandleIndex = Constants.CommonInputHandleIndex,
                RestrictionData = restrictionData,
                SearchFlags = uint.MaxValue,
                FolderIdCount = (ushort)folderIds.Length,
                FolderIds = folderIds
            };
            setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles);

            #region Verify the requirements: MS-OXCFOLD_R116001, MS-OXCFOLD_R1091, MS-OXCFOLD_R1092, and MS-OXCFOLD_R116002.

            if (Common.IsRequirementEnabled(116001, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R116001");

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R116001
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x80070057,
                    setSearchCriteriaResponse.ReturnValue,
                    116001,
                    @"[In Appendix A: Product Behavior] If the client sets an invalid bit in the SearchFlags field, implementation does fail the RopSetSearchCriteria ROP operation with ecInvalidParam (0x80070057). (Microsoft Exchange 2010 and above follow this behavior.)");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1091");

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1091
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x80070057,
                    setSearchCriteriaResponse.ReturnValue,
                    1091,
                    @"[In Processing a RopSetSearchCriteria ROP Request] The value of error code ecInvalidParam is 0x80070057.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1092");

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1092
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x80070057,
                    setSearchCriteriaResponse.ReturnValue,
                    1092,
                    @"[In Processing a RopSetSearchCriteria ROP Request] When the error code is ecInvalidParam, it indicates the SearchFlags field contains an invalid value.");
            }

            if (Common.IsRequirementEnabled(116002, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R116002");

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R116002
                Site.CaptureRequirementIfAreNotEqual<uint>(
                    0x80070057,
                    setSearchCriteriaResponse.ReturnValue,
                    116002,
                    @"[In Appendix A: Product Behavior] If the client sets an invalid bit in the SearchFlags field, implementation does not fail the RopSetSearchCriteria ROP operation with ecInvalidParam (0x80070057). <17> Section 3.2.5.4: Exchange 2007 silently ignores invalid bits and does not return the ecInvalidParam error code.");
            }

            #endregion

            #endregion

            #region Step 5. The client calls RopSetSearchCriteria with no folder ID specified for search folder [MSOXCFOLDSearchFolder1] which is not initialized.
            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);

            #region Verify the requirements: MS-OXCFOLD_R565, MS-OXCFOLD_R566 and MS-OXCFOLD_R1240.

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R565");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R565.
            Site.CaptureRequirementIfAreEqual<uint>(
                0x80040605,
                setSearchCriteriaResponse.ReturnValue,
                565,
                @"[In Processing a RopSetSearchCriteria ROP Request] The value of error code ecNotInitialized is 0x80040605.");

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1240: the return value of RopSetSearchCriteria request with no FIDs is {0}", setSearchCriteriaResponse.ReturnValue);

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1240.
            Site.CaptureRequirementIfAreEqual<uint>(
                0x80040605,
                setSearchCriteriaResponse.ReturnValue,
                1240,
                @"[In Processing a RopSetSearchCriteria ROP Request] If the client does not specify FIDs, as specified in ([MS-OXCDATA] section 2.2.1.1), in the initial RopSetSearchCriteria ROP request, the server fails the ROP with ecNotInitialized (0x80040605).");

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R566");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R566.
            // The clients call RopSetSearchCriteria ROP on a not initialized search folder without setting folder IDs, and the error code 0x80040605 was captured, MS-OXCFOLD_R566 can be verified directly.
            Site.CaptureRequirement(
                566,
                @"[In Processing a RopSetSearchCriteria ROP Request] When the error code is ecNotInitialized, it indicates that no FIDs were specified for this search folder.");
            #endregion
            #endregion

            #region Step 6. The client calls RopSetSearchCriteria with [MSOXCFOLDSearchFolder1] was included in its own search scope.

            setSearchCriteriaRequest = new RopSetSearchCriteriaRequest
            {
                RopId = (byte)RopId.RopSetSearchCriteria,
                LogonId = Constants.CommonLogonId,
                InputHandleIndex = Constants.CommonInputHandleIndex,
                RestrictionDataSize = 0x0005,
                RestrictionData = restrictionData,
                SearchFlags = (uint)SetSearchFlags.RestartSearch,
                FolderIds = new ulong[] { searchFolderID },
                FolderIdCount = 1,
            };
            #region Verify the requirements: MS-OXCFOLD_R124201, MS-OXCFOLD_R124202, MS-OXCFOLD_R1243 and MS-OXCFOLD_R1244.

            if (Common.IsRequirementEnabled(124201, this.Site))
            {
                setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles);

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R124201: the return value of the RopSetSearchCriteria is {0}", setSearchCriteriaResponse.ReturnValue);

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R124201
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x00000490,
                    setSearchCriteriaResponse.ReturnValue,
                    124201,
                    @"[In Appendix A: Product Behavior] Implementation does fail the ROP with ecSearchFolderScopeViolation (0x00000490), if the client sets the search scope to include the search folder itself. (Exchange 2013 and above follows this behavior.)");
                
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1243: the return value of the RopSetSearchCriteria is {0}", setSearchCriteriaResponse.ReturnValue);

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1243
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x00000490,
                    setSearchCriteriaResponse.ReturnValue,
                    1243,
                    @"[In Processing a RopSetSearchCriteria ROP Request] The value of error code ecSearchFolderScopeViolation is 0x00000490.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R1244: the return value of the RopSetSearchCriteria is {0}", setSearchCriteriaResponse.ReturnValue);

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R1244
                // The client calls RopSetSearchCriteria with [MSOXCFOLDSearchFolder1] was included in its own search scope, so if the return value is ecSearchFolderScopeViolation, R1244 can be verified.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x00000490,
                    setSearchCriteriaResponse.ReturnValue,
                    1244,
                    @"[In Processing a RopSetSearchCriteria ROP Request] When the error code is ecSearchFolderScopeViolation, it indicates the search folder was included in its own search scope.");
            }

            if (Common.IsRequirementEnabled(124202, this.Site))
            {
                setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles);

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R124202: the return value of the RopSetSearchCriteria is {0}", setSearchCriteriaResponse.ReturnValue);

                // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R124202
                Site.CaptureRequirementIfAreEqual<uint>(
                    0,
                    setSearchCriteriaResponse.ReturnValue,
                    124202,
                    @"[In Appendix A: Product Behavior] Implementation does not fail the RopSetSearchCriteria ROP when the search folder is included in its own search scope. <16> Section 3.2.5.4:  Exchange 2007, and Exchange 2010 do not fail the RopSetSearchCriteria ROP when the search folder is included in its own search scope.");
            }
            #endregion
            #endregion
        }