Microsoft.Protocols.TestSuites.MS_OXCSTOR.S02_PublicFoldersLogon.MSOXCSTOR_S02_TC04_TestInvalidOperationsLogonPublicfolders C# (CSharp) Method

MSOXCSTOR_S02_TC04_TestInvalidOperationsLogonPublicfolders() private method

        public void MSOXCSTOR_S02_TC04_TestInvalidOperationsLogonPublicfolders()
        {
            this.CheckTransportIsSupported();

            #region step1: Connect to server1
            this.returnStatus = this.oxcstorAdapter.ConnectEx(ConnectionType.PrivateMailboxServer);
            Site.Assert.IsTrue(this.returnStatus, "Connection is successful");
            #endregion

            #region step2: RopLogon to log on to the private mailbox

            this.oxcstorAdapter.DoRopCall(this.logonRequestForPrivateMailBox, this.insideObjHandle, ROPCommandType.RopLogonPrivateMailbox, out this.outputBuffer);
            this.logonResponse = (RopLogonResponse)this.outputBuffer.RopsList[0];

            this.outObjHandle = this.outputBuffer.ServerObjectHandleTable[0];
            Site.Assert.AreEqual<uint>(
                0x00000000,
                this.logonResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion

            #region Capture

            // Local Site's Free/Busy Data Folder
            this.getOwningServersRequest.FolderId = this.logonResponse.FolderIds[7];
            this.oxcstorAdapter.DoRopCall(this.getOwningServersRequest, this.outObjHandle, ROPCommandType.RopGetOwningServers, out this.outputBuffer);
            this.getOwningServersResponse = (RopGetOwningServersResponse)this.outputBuffer.RopsList[0];

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R892
            Site.CaptureRequirementIfAreNotEqual<uint>(
                0,
                getOwningServersResponse.ReturnValue,
                892,
                @"[In Receiving a RopGetOwningServers ROP Request] If the operation is performed against a private mailbox message store, the server can fail the operation, or it can compute a correct answer for the client.");
            #endregion

            #region step3: RopGetReceiveFolder ROP
            this.getReceiveFolderRequest.MessageClass = Encoding.ASCII.GetBytes("IPM\0");
            this.oxcstorAdapter.DoRopCall(this.getReceiveFolderRequest, this.outObjHandle, ROPCommandType.RopGetReceiveFolder, out this.outputBuffer);
            RopGetReceiveFolderResponse getReceiveFolderForPrivateMailboxResponse;
            getReceiveFolderForPrivateMailboxResponse = (RopGetReceiveFolderResponse)this.outputBuffer.RopsList[0];
            #endregion RopGetReceiveFolder ROP

            #region step4: RopSetReceiveFolder ROP
            this.setReceiveFolderRequest.FolderId = this.logonResponse.FolderIds[4];
            this.oxcstorAdapter.DoRopCall(this.setReceiveFolderRequest, this.outObjHandle, ROPCommandType.RopSetReceiveFolder, out this.outputBuffer);
            RopSetReceiveFolderResponse setReceiveFolderForPrivateMailboxResponse;
            setReceiveFolderForPrivateMailboxResponse = (RopSetReceiveFolderResponse)this.outputBuffer.RopsList[0];
            #endregion RopSetReceiveFolder ROP

            #region step5: RopGetReceiveFolderTable ROP
            this.oxcstorAdapter.DoRopCall(this.getReceiveFolderTableRequest, this.outObjHandle, ROPCommandType.RopGetReceiveFolderTable, out this.outputBuffer);
            RopGetReceiveFolderTableResponse getReceiveFolderTableForPrivateMailboxResponse = (RopGetReceiveFolderTableResponse)this.outputBuffer.RopsList[0];
            #endregion RopGetReceiveFolderTable ROP

            #region Step6: RopGetPerUserLongTermIds ROP
            this.longTermIdFromIdRequest.ObjectId = this.logonResponse.FolderIds[0];
            this.oxcstorAdapter.DoRopCall(this.longTermIdFromIdRequest, this.outObjHandle, ROPCommandType.RopLongTermIdFromId, out this.outputBuffer);
            this.longTermIdFromIdResponse = (RopLongTermIdFromIdResponse)this.outputBuffer.RopsList[0];

            Site.Assert.AreEqual<uint>(
                0x00000000,
                this.longTermIdFromIdResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");

            this.getPerUserLongTermIdsRequest.DatabaseGuid = this.longTermIdFromIdResponse.LongTermId.DatabaseGuid;

            this.oxcstorAdapter.DoRopCall(this.getPerUserLongTermIdsRequest, this.outObjHandle, ROPCommandType.RopGetPerUserLongTermIds, out this.outputBuffer);
            RopGetPerUserLongTermIdsResponse getPerUserLongTermIdsForPrivateMailboxResponse;
            getPerUserLongTermIdsForPrivateMailboxResponse = (RopGetPerUserLongTermIdsResponse)this.outputBuffer.RopsList[0];

            Site.Assert.AreEqual<uint>(
                0x00000000,
                getPerUserLongTermIdsForPrivateMailboxResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion RopGetPerUserLongTermIds ROP

            #region Step7: Disconnect
            this.returnStatus = this.oxcstorAdapter.DisconnectEx();
            Site.Assert.IsTrue(this.returnStatus, "Disconnection is successful");
            #endregion

            #region step8: Connect to server1
            this.returnStatus = this.oxcstorAdapter.ConnectEx(ConnectionType.PublicFolderServer);
            Site.Assert.IsTrue(this.returnStatus, "Connection is successful");
            #endregion

            #region step9: RopLogon ROP to public folders
            this.oxcstorAdapter.DoRopCall(this.logonRequestForPublicFolder, this.insideObjHandle, ROPCommandType.RopLogonPublicFolder, out this.outputBuffer);
            this.logonResponse = (RopLogonResponse)this.outputBuffer.RopsList[0];
            this.outObjHandle = this.outputBuffer.ServerObjectHandleTable[0];
            Site.Assert.AreEqual<uint>(
                0x00000000,
                this.logonResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion

            #region step10: RopGetReceiveFolder ROP
            this.oxcstorAdapter.DoRopCall(this.getReceiveFolderRequest, this.outObjHandle, ROPCommandType.RopGetReceiveFolder, out this.outputBuffer);
            #endregion RopGetReceiveFolder ROP

            RopGetReceiveFolderResponse getReceiveFolderForPublicFoldersResponse;
            getReceiveFolderForPublicFoldersResponse = (RopGetReceiveFolderResponse)this.outputBuffer.RopsList[0];

            #region Capture
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R59782");

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R59782
            // In the step 3, call RopGetReceiveFolder for a private mailbox and in the step 10 call RopGetReceiveFolder for public folders.
            // If successful in the step 3 and failed in the step 8, MS-OXCSTOR_R59782 can be verified.
            bool isVerifyR59782 = getReceiveFolderForPrivateMailboxResponse.ReturnValue == 0 && getReceiveFolderForPublicFoldersResponse.ReturnValue != 0;
            Site.CaptureRequirementIfIsTrue(
                isVerifyR59782,
                59782,
                @"[In Receiving a RopGetReceiveFolder ROP Request] The server verifies that the operation is being performed against a private mailbox logon, and not a public folders logon.");
            #endregion

            #region step11: RopSetReceiveFolder ROP
            this.setReceiveFolderRequest.FolderId = this.logonResponse.FolderIds[4];
            this.oxcstorAdapter.DoRopCall(this.setReceiveFolderRequest, this.outObjHandle, ROPCommandType.RopSetReceiveFolder, out this.outputBuffer);
            RopSetReceiveFolderResponse setReceiveFolderForPublicFoldersResponse;
            setReceiveFolderForPublicFoldersResponse = (RopSetReceiveFolderResponse)this.outputBuffer.RopsList[0];
            #endregion RopSetReceiveFolder ROP

            #region Capture
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R855");

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R855
            // In the step 4, call RopSetReceiveFolder for a private mailbox and in the step 11 call RopSetReceiveFolder for public folders.
            // If successful in the step 4 and failed in the step 11, this requirement can be verified.
            bool isVerify_R855 = setReceiveFolderForPrivateMailboxResponse.ReturnValue == 0 && setReceiveFolderForPublicFoldersResponse.ReturnValue != 0;
            Site.CaptureRequirementIfIsTrue(
                isVerify_R855,
                855,
                @"[In Receiving a RopSetReceiveFolder ROP Request] The server verifies that the operation is being performed against a private mailbox logon, and not a public folders logon.");
            #endregion

            #region step12: RopGetReceiveFolderTable ROP
            this.oxcstorAdapter.DoRopCall(this.getReceiveFolderTableRequest, this.outObjHandle, ROPCommandType.RopGetReceiveFolderTable, out this.outputBuffer);
            RopGetReceiveFolderTableResponse getReceiveFolderTableForPublicFosderResponse;
            getReceiveFolderTableForPublicFosderResponse = (RopGetReceiveFolderTableResponse)this.outputBuffer.RopsList[0];
            #endregion RopGetReceiveFolderTable ROP

            #region Capture
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R874");

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R874
            // In the step 5, call RopGetReceiveFolderTable for a private mailbox and in the step 12 call RopGetReceiveFolderTable for public folders.
            // If successful in the step 5 and failed in the step 12, this requirement can be verified.
            bool isVerify_R874 = getReceiveFolderTableForPrivateMailboxResponse.ReturnValue == 0 && getReceiveFolderTableForPublicFosderResponse.ReturnValue != 0;
            Site.CaptureRequirementIfIsTrue(
                isVerify_R874,
                874,
                @"[In Receiving a RopGetReceiveFolderTable ROP Request] The server verifies that the operation is being performed against a private mailbox logon, and not a public folders logon.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R875
            Site.CaptureRequirementIfAreEqual<uint>(
                0x80040102,
                getReceiveFolderTableForPublicFosderResponse.ReturnValue,
                875,
                @"[In Receiving a RopGetReceiveFolderTable ROP Request] If the operation is performed against a public folders logon, the server MUST fail the operation with a ReturnValue of 0x80040102.");
            #endregion

            #region step13: RopGetPerUserLongTermIds ROP against the public folder logon
            this.getPerUserLongTermIdsRequest.DatabaseGuid = new byte[16];
            this.oxcstorAdapter.DoRopCall(this.getPerUserLongTermIdsRequest, this.outObjHandle, ROPCommandType.RopGetPerUserLongTermIds, out this.outputBuffer);
            RopGetPerUserLongTermIdsResponse getPerUserLongTermIdsForPublicFoldersResponse;
            getPerUserLongTermIdsForPublicFoldersResponse = (RopGetPerUserLongTermIdsResponse)this.outputBuffer.RopsList[0];
            #endregion RopGetPerUserLongTermIds ROP

            #region Capture
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R59770");

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R59770
            // Step 6 calls RopGetPerUserLongTermIds for a private mailbox and step 13 calls RopGetPerUserLongTermIds for public folders.
            // If successful in the step 6 and failed in the step 13, this requirement can be verified.
            bool isVerifyR59770 = getPerUserLongTermIdsForPrivateMailboxResponse.ReturnValue == 0 && getPerUserLongTermIdsForPublicFoldersResponse.ReturnValue != 0;
            Site.CaptureRequirementIfIsTrue(
                isVerifyR59770,
                59770,
                @"[In Receiving a RopGetPerUserLongTermIds ROP Request] The server verifies that the operation is being performed against a private mailbox logon, not against a public folders logon.");

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

            // Step 13 calls RopGetPerUserLongTermIds for public folders.
            // If the return value is 0x80040102, R59771 is verified.
            Site.CaptureRequirementIfAreEqual(
                0x80040102,
                getPerUserLongTermIdsForPublicFoldersResponse.ReturnValue,
                59771,
                @"[In Receiving a RopGetPerUserLongTermIds ROP Request] If the operation is performed against a public folders logon, the server MUST fail the operation with a ReturnValue of 0x80040102.");

            #endregion
        }