public void MSASCMD_S21_TC14_CommonStatusCode_145()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "This test case is not supported when the MS-ASProtocolVersion header is set to 12.1.. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region User calls Provision command to download policies from server
            // Calls Provision command to download policies
            ProvisionRequest  provisionRequest  = TestSuiteBase.GenerateDefaultProvisionRequest();
            ProvisionResponse provisionResponse = this.CMDAdapter.Provision(provisionRequest);


            // Get policyKey, policyType and statusCode from server response
            string policyKey = null;
            if (null != provisionResponse.ResponseData.Policies)
            {
                Response.ProvisionPoliciesPolicy policyInResponse = provisionResponse.ResponseData.Policies.Policy;
                if (policyInResponse != null)
                {
                    policyKey = policyInResponse.PolicyKey;
                }
            }

            string policyType = provisionResponse.ResponseData.Policies.Policy.PolicyType;
            Response.ProvisionPoliciesPolicyData data = provisionResponse.ResponseData.Policies.Policy.Data;
            byte statusCode = provisionResponse.ResponseData.Status;
            #endregion

            #region User calls Provision command to acknowledge policies.

            // Set acknowledgeStatus value to 1, means accept the policy.
            ProvisionRequest provisionAcknowledgeRequest = TestSuiteBase.GenerateDefaultProvisionRequest();
            provisionAcknowledgeRequest.RequestData.Policies.Policy.PolicyKey = policyKey;
            provisionAcknowledgeRequest.RequestData.Policies.Policy.Status    = "4";

            // Calls Provision command
            ProvisionResponse provisionAcknowledgeResponse = this.CMDAdapter.Provision(provisionAcknowledgeRequest);
            statusCode = provisionAcknowledgeResponse.ResponseData.Status;

            this.Site.CaptureRequirementIfAreEqual <byte>(
                145,
                statusCode,
                4917,
                @"[In Common Status Codes] When the protocol version is 14.0, 14.1 or 16.0,  [The meaning of the status value 145 is] The device claimed to be externally managed, but the server doesn't allow externally managed devices to sync.");
            #endregion
        }
        public void MSASCMD_S12_TC01_Provision_DownloadPolicy()
        {
            #region User calls Provision command to download policies from server
            // Calls Provision command to download policies
            ProvisionRequest  provisionRequest  = TestSuiteBase.GenerateDefaultProvisionRequest();
            ProvisionResponse provisionResponse = this.CMDAdapter.Provision(provisionRequest);

            // Get policyKey, policyType and statusCode from server response
            string policyKey  = GetPolicyKeyFromResponse(provisionResponse);
            string policyType = provisionResponse.ResponseData.Policies.Policy.PolicyType;
            Response.ProvisionPoliciesPolicyData data = provisionResponse.ResponseData.Policies.Policy.Data;
            byte statusCode = provisionResponse.ResponseData.Status;
            #endregion

            #region Verify Requirements MS-ASCMD_R5026, MS-ASCMD_R4990, MS-ASCMD_R4992
            // If User calls Provision command to download policies successful, server will return policyKey, policyType, data and statusCode in response, then MS-ASCMD_R5026, MS-ASCMD_R4990, MS-ASCMD_R4992 are verified.
            // The policy settings with the format specified in PolicyType element, are contained in Data element of Provision command response.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5026");

            // Verify MS-ASCMD requirement: MS-ASCMD_R5026
            Site.CaptureRequirementIfIsTrue(
                policyKey != null && policyType != null && data != null && statusCode == 1,
                5026,
                @"[In Downloading Policy Settings] [Provision sequence for downloading policy settings, order 1:] The server responds with the policy type, policy key, data, and status code.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4990
            Site.CaptureRequirementIfIsTrue(
                policyKey != null && policyType != null && data != null,
                4990,
                @"[In Downloading Policy Settings] The server then responds with the provision:PolicyType, provision:PolicyKey (as specified in [MS-ASPROV] section 2.2.2.41), and provision:Data ([MS-ASPROV] section 2.2.2.23) elements.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4992
            Site.CaptureRequirementIfIsTrue(
                policyType != null && data != null,
                4992,
                @"[In Downloading Policy Settings] The policy settings, in the format specified in the provision:PolicyType element, are contained in the provision:Data element.");
            #endregion

            #region User calls Provision command to acknowledge policies.

            // Set acknowledgeStatus value to 1, means accept the policy.
            string           acknowledgeStatus           = "1";
            ProvisionRequest provisionAcknowledgeRequest = TestSuiteBase.GenerateDefaultProvisionRequest();
            provisionAcknowledgeRequest.RequestData.Policies.Policy.PolicyKey = policyKey;
            provisionAcknowledgeRequest.RequestData.Policies.Policy.Status    = acknowledgeStatus;

            // Calls Provision command
            ProvisionResponse provisionAcknowledgeResponse = this.CMDAdapter.Provision(provisionAcknowledgeRequest);

            // Get policyKey, policyType and status code from server response
            policyKey  = GetPolicyKeyFromResponse(provisionAcknowledgeResponse);
            policyType = provisionAcknowledgeResponse.ResponseData.Policies.Policy.PolicyType;
            statusCode = provisionAcknowledgeResponse.ResponseData.Policies.Policy.Status;

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5028
            Site.CaptureRequirementIfIsTrue(
                policyKey != null && policyType != null && statusCode == 1,
                5028,
                @"[In Downloading Policy Settings] [Provision sequence for downloading policy settings, order 2:] The server responds with the policy type, policy key, and status code to indicate that the server recorded the client's acknowledgement.");
            #endregion
        }