Microsoft.Protocols.TestSuites.MS_OXCMAPIHTTP.AdapterHelper.GetFinalResponseCode C# (CSharp) Method

GetFinalResponseCode() public static method

Get the final value of X-ResponseCode header.
public static GetFinalResponseCode ( string responseCode ) : uint
responseCode string The value of X-ResponseCode header returned from server.
return uint
        public static uint GetFinalResponseCode(string responseCode)
        {
            if (string.IsNullOrEmpty(responseCode))
            {
                return 0;
            }

            string[] responseCodeValues = responseCode.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            uint finalResponseCode = uint.Parse(responseCodeValues[responseCodeValues.Length - 1]);

            return finalResponseCode;
        }
        #endregion Methods

Usage Example

        /// <summary>
        /// Send the request to address book server endpoint.
        /// </summary>
        /// <param name="requestBody">The request body.</param>
        /// <param name="requestType">The type of the request.</param>
        /// <param name="cookieChange">If the session context cookie changed.</param>
        /// <returns>The common response.</returns>
        private CommonResponse SendAddressBookRequest(IRequestBody requestBody, RequestType requestType, bool cookieChange = true)
        {
            byte[]              rawBuffer;
            CommonResponse      commonResponse      = null;
            WebHeaderCollection webHeaderCollection = AdapterHelper.InitializeHTTPHeader(requestType, AdapterHelper.ClientInstance, AdapterHelper.Counter);

            // Send the Execute HTTP request and get the response.
            HttpWebResponse response     = this.SendMAPIHttpRequest(this.userName, this.password, requestBody, ServerEndpoint.AddressBookServerEndpoint, AdapterHelper.SessionContextCookies, webHeaderCollection, out rawBuffer);
            uint            responseCode = AdapterHelper.GetFinalResponseCode(response.Headers["X-ResponseCode"]);

            this.Site.Assert.AreEqual <uint>(0, responseCode, "The request to the address book server should be executed successfully!");

            // Read the HTTP response buffer and parse the response to correct format.
            commonResponse = CommonResponse.ParseCommonResponse(rawBuffer);
            Site.Assert.IsNotNull(commonResponse.ResponseBodyRawData, "The response body should contains data.");
            this.VerifyRequestTypesForAddressBookServerEndpoint(response.Headers, commonResponse);
            this.VerifyAutoDiscover(response.StatusCode, ServerEndpoint.AddressBookServerEndpoint);
            this.VerifyAuthentication(response);

            response.GetResponseStream().Close();
            if (cookieChange)
            {
                AdapterHelper.SessionContextCookies = response.Cookies;
            }

            return(commonResponse);
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.MS_OXCMAPIHTTP.AdapterHelper::GetFinalResponseCode