Microsoft.Protocols.TestSuites.MS_ASRM.TestSuiteBase.GetTemplateID C# (CSharp) Method

GetTemplateID() protected method

Call Settings command to get the expected template ID for template name
protected GetTemplateID ( string templateName ) : string
templateName string A string that specifies the name of the rights policy template.
return string
        protected string GetTemplateID(string templateName)
        {
            // Get the template settings
            SettingsResponse settingsResponse = this.ASRMAdapter.Settings();

            // Choose the all rights policy template and get template ID.
            this.Site.Assert.IsNotNull(settingsResponse.ResponseData.RightsManagementInformation, "The RightsManagementInformation element should not be null in Settings response.");
            this.Site.Assert.IsNotNull(settingsResponse.ResponseData.RightsManagementInformation.Get, "The Get element should not be null in Settings response.");
            this.Site.Assert.IsNotNull(settingsResponse.ResponseData.RightsManagementInformation.Get.RightsManagementTemplates, "The RightsManagementTemplates element should not be null in Settings response.");
            string templateID = null;
            foreach (Response.RightsManagementTemplatesRightsManagementTemplate template in settingsResponse.ResponseData.RightsManagementInformation.Get.RightsManagementTemplates)
            {
                if (template.TemplateName == templateName)
                {
                    templateID = template.TemplateID;
                    break;
                }
            }

            this.Site.Assert.IsNotNull(templateID, "Template {0} is not found on the server. This may happen if MS-ASRM configuration is not performed properly.", templateName);
            return templateID;
        }