Microsoft.Protocols.TestSuites.MS_OXCSTOR.MS_OXCSTORAdapter.VerifyRopGetReceiveFolder C# (CSharp) Method

VerifyRopGetReceiveFolder() private method

Verify the response by sending the ROP RopGetReceiveFolder.
private VerifyRopGetReceiveFolder ( RopGetReceiveFolderResponse response ) : void
response Microsoft.Protocols.TestSuites.Common.RopGetReceiveFolderResponse The structure of ROP RopGetReceiveFolder response.
return void
        private void VerifyRopGetReceiveFolder(RopGetReceiveFolderResponse response)
        {
            // The return value is 0 to indicate that the response is successful.
            if (response.ReturnValue == 0)
            {
                if (response.MessageClass != null)
                {
                    // If there is one character value in the string is not in the numeric range of 0 to 127,  this value will be false.   
                    bool isASCII = Common.IsNullTerminatedASCIIStr(response.MessageClass);

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

                    // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R212
                    // The method ToString is used to decode the stream with ASCII, so if the result is not null, this stream must use ASCII encoding.
                    Site.CaptureRequirementIfIsTrue(
                        isASCII,
                        212,
                        @"[In RopGetReceiveFolder ROP Success Response Buffer] ExplicitMessageClass: The string [Contained by ExplicitMessageClass] MUST meet the following requirement: The string uses ASCII encoding.");

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R213, the length of the MessageClass is: {0}.", response.MessageClass.Length);

                    // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R213
                    // Check if the MessageClass string length is greater than zero and less than or equal to 255.
                    bool isVerifyR213 =
                        (response.MessageClass.Length > 0) &&
                        (response.MessageClass.Length <= 255);

                    Site.CaptureRequirementIfIsTrue(
                        isVerifyR213,
                        213,
                        @"[In RopGetReceiveFolder ROP Success Response Buffer] ExplicitMessageClass: The string [Contained by ExplicitMessageClass] MUST meet the following requirement: The length (including the terminating NULL character) is greater than zero and less than or equal to 255.");

                    // If MessageClass field only contains a terminating NULL character, ignore this requirement R214
                    if (response.MessageClass[0] != 0x00)
                    {
                        // If there is one character value in the string is not in the numeric range of 32 to 126,  this value will be false.
                        bool isValidateValue = true;

                        // The last element in MessageClass is a terminating NULL character, so the length minus one here. 
                        for (int i = 0; i < response.MessageClass.Length - 1; i++)
                        {
                            byte elem = response.MessageClass[i];

                            // Check if each character value in the string is in the numeric range of 32 to 126
                            if ((elem < 32) || (elem > 126))
                            {
                                isValidateValue = false;
                                break;
                            }
                        }

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

                        // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R214
                        Site.CaptureRequirementIfIsTrue(
                            isValidateValue,
                            214,
                            @"[In RopGetReceiveFolder ROP Success Response Buffer] ExplicitMessageClass: The string [Contained by ExplicitMessageClass] MUST meet the following requirement: Each character value in the string is in the numeric range of 32 to 126, inclusive.");
                    }

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

                    // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R215
                    // Check if the first byte in the byte array (response.MessageClass[0]) is not the character ".".
                    Site.CaptureRequirementIfAreNotEqual<byte>(
                       (byte)'.',
                        response.MessageClass[0],
                        215,
                        @"[In RopGetReceiveFolder ROP Success Response Buffer] ExplicitMessageClass: The string [Contained by ExplicitMessageClass] MUST meet the following requirement: The string does not begin with a period (""."").");

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

                    // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R216
                    // Check if the last byte in the byte array (response.MessageClass[response.MessageClass.Length - 1]) is not the character ".".
                    Site.CaptureRequirementIfAreNotEqual<byte>(
                        (byte)'.',
                        response.MessageClass[response.MessageClass.Length - 1],
                        216,
                        @"[In RopGetReceiveFolder ROP Success Response Buffer] ExplicitMessageClass: The string [Contained by ExplicitMessageClass] MUST meet the following requirement: The string does not end with a period.");

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R217, the MessageClass is: {0}.", response.MessageClass.ToString());

                    // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R217
                    bool isVerifyR217 = true;

                    // Check if the element contained in the MessageClass buffer does not contain the adjacent period character "-".
                    foreach (byte elem in response.MessageClass)
                    {
                        if (elem == (byte)'-')
                        {
                            isVerifyR213 = false;
                            break;
                        }
                    }

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

                    Site.CaptureRequirementIfIsTrue(
                        isVerifyR217,
                        217,
                        @"[In RopGetReceiveFolder ROP Success Response Buffer] ExplicitMessageClass: The string [Contained by ExplicitMessageClass] MUST meet the following requirement: The string does not contain adjacent periods.");

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

                    // If the response can be parsed successfully and the return value is success, indicates the ROP's functionality is consistent with its description.
                    Site.CaptureRequirement(
                        197,
                        @"[In RopGetReceiveFolder ROP] This ROP [RopGetReceiveFolder] also returns the specific parent message class configured to deliver to that folder.");
                }
            }
        }