/// <summary>
        /// Clean up the test.
        /// </summary>
        protected override void TestCleanup()
        {
            if (this.isReceiveNewMail == true)
            {
                WebHeaderCollection headers = new WebHeaderCollection();
                MailboxResponseBodyBase response;

                #region Send a valid Connect request type to establish a Session Context with the server.
                ConnectSuccessResponseBody connectResponse = this.ConnectToServer(out headers);
                #endregion

                #region Send an Execute request that incluldes Logon ROP to server.
                WebHeaderCollection executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);

                ExecuteRequestBody requestBody = this.InitializeExecuteRequestBody(this.GetRopLogonRequest());
                List<string> metaTags = new List<string>();

                ExecuteSuccessResponseBody executeSuccessResponse = this.SendExecuteRequest(requestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;

                ulong folderId;
                RopLogonResponse logonResponse = new RopLogonResponse();
                uint logonHandle = this.ParseLogonResponse(executeSuccessResponse.RopBuffer, out folderId, out logonResponse);
                #endregion

                #region Send an Execute request to open inbox folder.
                RPC_HEADER_EXT[] rpcHeaderExts;
                byte[][] rops;
                uint[][] serverHandleObjectsTables;
                RopOpenFolderRequest openFolderRequest = this.OpenFolderRequest(logonResponse.FolderIds[4]);

                ExecuteRequestBody openFolderRequestBody = this.InitializeExecuteRequestBody(openFolderRequest, logonHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(openFolderRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;

                RopBufferHelper ropBufferHelper = new RopBufferHelper(Site);
                ropBufferHelper.ParseResponseBuffer(executeSuccessResponse.RopBuffer, out rpcHeaderExts, out rops, out serverHandleObjectsTables);
                RopOpenFolderResponse openFolderResponse = new RopOpenFolderResponse();
                openFolderResponse.Deserialize(rops[0], 0);
                 uint folderHandle = serverHandleObjectsTables[0][openFolderResponse.OutputHandleIndex];
                #endregion

                #region Send an Execute request type to hard delete messages in inbox folder.
                RopHardDeleteMessagesAndSubfoldersRequest hardDeleteRequest;
                hardDeleteRequest.RopId = (byte)RopId.RopHardDeleteMessagesAndSubfolders;
                hardDeleteRequest.LogonId = ConstValues.LogonId;

                // Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table
                // where the handle for the input Server object is stored.
                hardDeleteRequest.InputHandleIndex = 0;
                hardDeleteRequest.WantAsynchronous = 0x00; // Synchronously
                hardDeleteRequest.WantDeleteAssociated = 0xFF; // TRUE: delete all messages and subfolders
                ExecuteRequestBody hardDeleteRequestBody = this.InitializeExecuteRequestBody(hardDeleteRequest, folderHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(hardDeleteRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;
                RopHardDeleteMessagesAndSubfoldersResponse hardDeleteMessagesAndSubfoldersResponse = new RopHardDeleteMessagesAndSubfoldersResponse();
                hardDeleteMessagesAndSubfoldersResponse.Deserialize(rops[0], 0);
                #endregion

                #region Send an Execute request to open sent items folder.
                openFolderRequest = this.OpenFolderRequest(logonResponse.FolderIds[6]);

                openFolderRequestBody = this.InitializeExecuteRequestBody(openFolderRequest, logonHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(openFolderRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;

                ropBufferHelper = new RopBufferHelper(Site);
                ropBufferHelper.ParseResponseBuffer(executeSuccessResponse.RopBuffer, out rpcHeaderExts, out rops, out serverHandleObjectsTables);
                openFolderResponse = new RopOpenFolderResponse();
                openFolderResponse.Deserialize(rops[0], 0);
                folderHandle = serverHandleObjectsTables[0][openFolderResponse.OutputHandleIndex];
                #endregion

                #region Send an Execute request type to hard delete messages in sent items folder.
                hardDeleteRequest.RopId = (byte)RopId.RopHardDeleteMessagesAndSubfolders;
                hardDeleteRequest.LogonId = ConstValues.LogonId;

                // Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table
                // where the handle for the input Server object is stored.
                hardDeleteRequest.InputHandleIndex = 0;
                hardDeleteRequest.WantAsynchronous = 0x00; // Synchronously
                hardDeleteRequest.WantDeleteAssociated = 0xFF; // TRUE: delete all messages and subfolders
                hardDeleteRequestBody = this.InitializeExecuteRequestBody(hardDeleteRequest, folderHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(hardDeleteRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;
                hardDeleteMessagesAndSubfoldersResponse = new RopHardDeleteMessagesAndSubfoldersResponse();
                hardDeleteMessagesAndSubfoldersResponse.Deserialize(rops[0], 0);
                #endregion

                #region Send a Disconnect request to destroy the Session Context.
                this.Adapter.Disconnect(out response);
                #endregion

                this.isReceiveNewMail = false;
            }

            base.TestCleanup();
        }
Пример #2
0
        /// <summary>
        /// Verify the response of RopHardDeleteMessagesAndSubfolders ROP operation.
        /// </summary>
        /// <param name="hardDeleteMessagesAndSubfoldersResponse">The response of RopHardDeleteMessagesAndSubfolders operation</param>
        private void VerifyRopHardDeleteMessagesAndSubfolders(RopHardDeleteMessagesAndSubfoldersResponse hardDeleteMessagesAndSubfoldersResponse)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R259");

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R259
            Site.CaptureRequirementIfAreEqual<uint>(
                Constants.SuccessCode,
                hardDeleteMessagesAndSubfoldersResponse.ReturnValue,
                259,
                @"[In RopHardDeleteMessagesAndSubfolders ROP Response Buffer] ReturnValue (4 bytes): The server returns 0x00000000 to indicate success.");

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

            // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R244
            Site.CaptureRequirementIfAreEqual<uint>(
                Constants.SuccessCode,
                hardDeleteMessagesAndSubfoldersResponse.ReturnValue,
                244,
                @"[In RopHardDeleteMessagesAndSubfolders ROP] The RopHardDeleteMessagesAndSubfolders ROP ([MS-OXCROPS] section 2.2.4.10) is used to hard delete all messages and subfolders from a folder without deleting the folder itself.");
        }
        /// <summary>
        /// Verify RopHardDeleteMessagesAndSubfolders Response
        /// </summary>
        /// <param name="ropHardDeleteMessagesAndSubfoldersResponse">The response of RopHardDeleteMessagesAndSubfolders request</param>
        /// <param name="inputHandleIndex">The field of InputHandleIndex in RopHardDeleteMessagesAndSubfolders request</param>
        private void VerifyRopHardDeleteMessagesAndSubfoldersResponse(RopHardDeleteMessagesAndSubfoldersResponse ropHardDeleteMessagesAndSubfoldersResponse, byte inputHandleIndex)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R917");

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R917
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropHardDeleteMessagesAndSubfoldersResponse.RopId.GetType(),
                917,
                @"[In RopHardDeleteMessagesAndSubfolders ROP Response Buffer] RopId (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R919
            Site.CaptureRequirementIfAreEqual<byte>(
                (byte)RopId.RopHardDeleteMessagesAndSubfolders,
                ropHardDeleteMessagesAndSubfoldersResponse.RopId,
                919,
                @"[In RopHardDeleteMessagesAndSubfolders ROP Response Buffer] RopId (1 byte): For this operation[RopHardDeleteMessagesAndSubfolders], this field[RopId (1 byte)] is set to 0x92.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R920
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropHardDeleteMessagesAndSubfoldersResponse.InputHandleIndex.GetType(),
                920,
                @"[In RopHardDeleteMessagesAndSubfolders ROP Response Buffer] InputHandleIndex (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R921
            Site.CaptureRequirementIfAreEqual<byte>(
                inputHandleIndex,
                ropHardDeleteMessagesAndSubfoldersResponse.InputHandleIndex,
                921,
                @"[In RopHardDeleteMessagesAndSubfolders ROP Response Buffer] InputHandleIndex (1 byte): This indexMUST be set to the value specified in the InputHandleIndex field in the request.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R922
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(uint),
                ropHardDeleteMessagesAndSubfoldersResponse.ReturnValue.GetType(),
                922,
                @"[In RopHardDeleteMessagesAndSubfolders ROP Response Buffer] ReturnValue (4 bytes): An unsigned integer.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R924,PartialCompletion:{0}", ropHardDeleteMessagesAndSubfoldersResponse.PartialCompletion);

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R924
            // If PartialCompletion is byte type and can be boolean type representation, then verify R924
            bool isVerifyR924 = (typeof(byte) == ropHardDeleteMessagesAndSubfoldersResponse.PartialCompletion.GetType()) &&
                                ((Convert.ToBoolean(ropHardDeleteMessagesAndSubfoldersResponse.PartialCompletion) == true) ||
                                (Convert.ToBoolean(ropHardDeleteMessagesAndSubfoldersResponse.PartialCompletion) == false));

            Site.CaptureRequirementIfIsTrue(
                isVerifyR924,
                924,
                @"[In RopHardDeleteMessagesAndSubfolders ROP Response Buffer] PartialCompletion (1 byte): A Boolean.");
        }