Microsoft.Protocols.TestSuites.SharedAdapter.MsfsshttpAdapterCapture.ValidateResponseElement C# (CSharp) Method

ValidateResponseElement() private static method

Capture requirements related with Response element.
private static ValidateResponseElement ( Response response, ITestSite site ) : void
response Microsoft.Protocols.TestSuites.Common.Response The Response information
site ITestSite Instance of ITestSite
return void
        private static void ValidateResponseElement(Response response, ITestSite site)
        {
            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R97
            site.CaptureRequirement(
                     "MS-FSSHTTP",
                     97,
                     @"[In Response][Response element schema is:]
                     <xs:element name=""Response"">
                       <!--Allows for the numbers to be displayed between the SubResponse elements-->
                       <xs:complexType mixed=""true"">
                         <xs:sequence minOccurs=""1"" maxOccurs=""unbounded"">
                           <xs:element name=""SubResponse"" type=""tns:SubResponseElementGenericType"" /> 
                         </xs:sequence>
                         <xs:attribute name=""Url"" type=""xs:string"" use=""required""/>
                         <xs:attribute name=""RequestToken"" type=""xs:nonNegativeInteger"" use=""required"" />
                         <xs:attribute name=""HealthScore"" type=""xs:integer"" use=""required""/>
                         <xs:attribute name=""ErrorCode"" type=""tns:GenericErrorCodeTypes"" use=""optional"" />
                         <xs:attribute name=""ErrorMessage"" type=""xs:string"" use=""optional""/>
                       </xs:complexType>
                     </xs:element>");

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R104
            site.Log.Add(
                LogEntryKind.Debug,
                "For requirement MS-FSSHTTP_R104, the Url attribute value should be specified, the actual Url value is: {0}",
                response.Url != null ? response.Url : "NULL");

            site.CaptureRequirementIfIsNotNull(
                     response.Url,
                     "MS-FSSHTTP",
                     104,
                     @"[In Response] The Url attribute MUST be specified for each Response element.");

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1482
            // The responseElement.SubResponse.Length specifies the number of SubResponse element in Response.
            bool isVerifiedR96 = response.SubResponse.Length >= 1;
            site.Log.Add(
                LogEntryKind.Debug,
                "For requirement MS-FSSHTTP_R1482, the Response element should contain one or more SubResponse elements, the actual SubResponse elements number is: {0}",
                response.SubResponse.Length.ToString());

            site.CaptureRequirementIfIsTrue(
                     isVerifiedR96,
                     "MS-FSSHTTP",
                     96,
                     @"[In Response] Each Response element MUST contain one or more SubResponse elements.");

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R107
            site.Log.Add(
                LogEntryKind.Debug,
                "For requirement MS-FSSHTTP_R263, the RequestToken should be specified, the actual RequestToken value is: {0}",
                response.RequestToken != null ? response.RequestToken : "NULL");

            site.CaptureRequirementIfIsNotNull(
                     response.RequestToken,
                     "MS-FSSHTTP",
                     107,
                     @"[In Response] The RequestToken MUST be specified for each Response element.");

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2076
            bool isVerifyR2076 = int.Parse(response.HealthScore) <= 10 && int.Parse(response.HealthScore) >= 0;
            site.Log.Add(
                LogEntryKind.Debug,
                "For requirement MS-FSSHTTP_R2076, the HealthScore value should be between 0 and 10, the actual HealthScore value is: {0}",
                response.HealthScore);

            site.CaptureRequirementIfIsTrue(
                     isVerifyR2076,
                     "MS-FSSHTTP",
                     2076,
                     @"[In Response] HealthScore: An integer which value is between 0 and 10.");

            // Verify requirements related with SubResponse element
            if (response.SubResponse != null)
            {
                foreach (SubResponseElementGenericType subResponse in response.SubResponse)
                {
                    ValidateSubResponseElement(subResponse, site);
                }
            }

            // Verify requirements related with GenericErrorCodeTypes
            if (response.ErrorCodeSpecified)
            {
                ValidateGenericErrorCodeTypes(site);
            }
        }