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

MSOXCSTOR_S02_TC03_TestPublicFolderIsGhosted() private method

private MSOXCSTOR_S02_TC03_TestPublicFolderIsGhosted ( ) : void
return void
        public void MSOXCSTOR_S02_TC03_TestPublicFolderIsGhosted()
        {
            this.CheckTransportIsSupported();

            #region Step1: connect
            this.returnStatus = this.oxcstorAdapter.ConnectEx(ConnectionType.PrivateMailboxServer);
            Site.Assert.IsTrue(this.returnStatus, "Connection is successful");
            this.oxcstorAdapter.SetAutoRedirect(true);
            #endregion

            #region Step2: RopLogon ROP to log on to the private mailbox
            this.logonRequestForPrivateMailBox.LogonFlags = (byte)LogonFlags.Private;
            this.logonRequestForPrivateMailBox.OpenFlags = 0x01000000;
            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 Step3: RopPublicFolderIsGhosted ROP against the private mailbox logon
            this.publicFolderIsGhostedRequest.FolderId = this.logonResponse.FolderIds[0];
            this.oxcstorAdapter.DoRopCall(this.publicFolderIsGhostedRequest, this.outObjHandle, ROPCommandType.RopPublicFolderIsGhosted, out this.outputBuffer);
            this.publicFolderIsGhostedResponse = (RopPublicFolderIsGhostedResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x00000000,
                this.publicFolderIsGhostedResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion

            #region Capture

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

            Site.CaptureRequirementIfAreEqual<byte>(
                0x00,
                this.publicFolderIsGhostedResponse.IsGhosted,
                917,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request] If the operation is issued against a private mailbox message store, the server MUST return FALSE in the IsGhosted field of the response.");

            // The Servers field of the RopPublicFolderIsGhosted ROP response is the replica information
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R1237");

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1237
            Site.CaptureRequirementIfIsNull(
                this.publicFolderIsGhostedResponse.Servers,
                1237,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request] In this case [if the operation is issued against a private mailbox store, the server MUST return FALSE in the IsGhosted field of the response], no replication state data is returned.");

            #endregion

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

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

            #region Step6: RopLogon ROP to log on to the public folder
            this.logonRequestForPublicFolder.OpenFlags = 0x01000202;
            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 Step7: RopPublicFolderIsGhosted ROP against the public folder logon
            this.publicFolderIsGhostedRequest.FolderId = this.logonResponse.FolderIds[0];
            this.oxcstorAdapter.DoRopCall(this.publicFolderIsGhostedRequest, this.outObjHandle, ROPCommandType.RopPublicFolderIsGhosted, out this.outputBuffer);

            RopPublicFolderIsGhostedResponse publicFolderIsGhostedResponse1;
            publicFolderIsGhostedResponse1 = (RopPublicFolderIsGhostedResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x00000000,
                this.publicFolderIsGhostedResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion this.publicFolderIsGhostedRequest

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R405
            // The default setting (after setup the test environment) is that the queried server is an active replica of the folder.
            Site.CaptureRequirementIfAreEqual<byte>(
                0,
                publicFolderIsGhostedResponse1.IsGhosted,
                405,
                @"[In RopPublicFolderIsGhosted ROP Success Response Buffer] otherwise [if the server is an active replica of the folder the IsGhosted flag] is FALSE.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R930
            // The default setting (after setup the test environment) is that the queried server is an active replica of the folder,  
            // Check if "IsGhost" is false to indirectly verify the queried server is listed.
            Site.CaptureRequirementIfAreEqual<byte>(
                0,
                publicFolderIsGhostedResponse1.IsGhosted,
                930,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request] The value of the IsGhosted field MUST be FALSE if the queried server is listed as an active replica of the folder.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R941
            bool isVerifiedR941 = (publicFolderIsGhostedResponse1.Servers == null && publicFolderIsGhostedResponse1.ServersCount == null) ||
                (publicFolderIsGhostedResponse1.Servers != null && publicFolderIsGhostedResponse1.ServersCount == publicFolderIsGhostedResponse1.Servers.Length);

            Site.CaptureRequirementIfIsTrue(
                isVerifiedR941,
                941,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request]  The current total list length constitutes the ServersCount return value.");
            #endregion

            #region Step8: RopPublicFolderIsGhosted ROP with invalid FolderId
            // A non-existing folder
            this.publicFolderIsGhostedRequest.FolderId = 0x01;
            this.oxcstorAdapter.DoRopCall(this.publicFolderIsGhostedRequest, this.outObjHandle, ROPCommandType.RopPublicFolderIsGhosted, out this.outputBuffer);
            RopPublicFolderIsGhostedResponse publicFolderIsGhostedInvalidResponse;
            publicFolderIsGhostedInvalidResponse = (RopPublicFolderIsGhostedResponse)this.outputBuffer.RopsList[0];
            #endregion

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1236
            Site.CaptureRequirementIfAreEqual<uint>(
                0x8004010F,
                publicFolderIsGhostedInvalidResponse.ReturnValue,
                1236,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request] If the public folder specified by the FolderId field cannot be found in the public folder container (either public folder database or public folder mailbox), the server MUST fail the operation with 0x8004010F (ecNotFound) in the ReturnValue field.");

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R436
            Site.CaptureRequirementIfAreEqual<uint>(
                0x8004010F,
                publicFolderIsGhostedInvalidResponse.ReturnValue,
                436,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request] The error code ecNotFound: Its value is 0x8004010F.");

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R437
            Site.CaptureRequirementIfAreEqual<uint>(
                0x8004010F,
                publicFolderIsGhostedInvalidResponse.ReturnValue,
                437,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request] The error code ecNotFound: The FID could not be found in the public folder container.");

            #endregion

            #region Step9:  RopPublicFolderIsGhosted ROP with the public folder = the IPM subtree root folders
            // According to the section 2.2.1.1.4 in the Open Specification, FolderIds[1] is Interpersonal Messages Sub-tree(IPM)
            this.publicFolderIsGhostedRequest.FolderId = this.logonResponse.FolderIds[1];
            this.oxcstorAdapter.DoRopCall(this.publicFolderIsGhostedRequest, this.outObjHandle, ROPCommandType.RopPublicFolderIsGhosted, out this.outputBuffer);
            this.publicFolderIsGhostedResponse = (RopPublicFolderIsGhostedResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x00000000,
                this.publicFolderIsGhostedResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion

            #region Step10: RopPublicFolderIsGhosted ROP with the public folder = non-IPM subtree
            // According to the section 2.2.1.1.4 in the Open Specification, FolderIds[2] is Non-interpersonal messages subtree(non-IPM)
            this.publicFolderIsGhostedRequest.FolderId = this.logonResponse.FolderIds[2];
            this.oxcstorAdapter.DoRopCall(this.publicFolderIsGhostedRequest, this.outObjHandle, ROPCommandType.RopPublicFolderIsGhosted, out this.outputBuffer);
            RopPublicFolderIsGhostedResponse pubFolderIsGhostResponse_non_IPM = (RopPublicFolderIsGhostedResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x00000000,
                pubFolderIsGhostResponse_non_IPM.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion

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

            // In step 9 the public folder is an IPM subtree and the response is publicFolderIsGhostedResponse.
            // When public folder is changed into a Non-interpersonal messages subtree, the response is pubFolderIsGhostResponse_non_IPM.
            // If both publicFolderIsGhostedResponse IsGhosted and pubFolderIsGhostResponse_non_IPM IsGhosted fields are 0, then MS-OXCSTOR_R1239 is verified.
            bool isVerifyR1239 = pubFolderIsGhostResponse_non_IPM.IsGhosted == 0 && this.publicFolderIsGhostedResponse.IsGhosted == 0;

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1239
            Site.CaptureRequirementIfIsTrue(
                isVerifyR1239,
                1239,
                @"[In Receiving a RopPublicFolderIsGhosted ROP Request] If the client issues this operation against the IPM subtree or the non-IPM subtree public folders, the value of the IsGhosted field MUST be FALSE.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1098
            // ServersCount is not present means the value of it is null.
            Site.Assert.AreEqual(0, this.publicFolderIsGhostedResponse.IsGhosted, "Check if the IsGhosted is 0(FALSE)");

            Site.CaptureRequirementIfIsNull(
                this.publicFolderIsGhostedResponse.ServersCount,
                1098,
                @"[In RopPublicFolderIsGhosted ROP Success Response Buffer] ServersCount: This field [ServersCount] is not present if the IsGhosted field is set to FALSE.");
            #endregion
        }