/// <summary> /// This operation is used to retrieve information about the collection of available site templates. /// </summary> /// <param name="lcid">Specifies the language code identifier (LCID).</param> /// <param name="templateList">SiteTemplates list.</param> /// <returns>The result of GetSiteTemplates operation which contains an error code to indicate whether the operation is succeed or an error type.</returns> public uint GetSiteTemplates(uint lcid, out Template[] templateList) { // Check whether GetSiteTemplates operation succeeds. uint getSiteTemplateResult = 1; templateList = null; getSiteTemplateResult = this.service.GetSiteTemplates(lcid, out templateList); // Verify the GetSiteTemplatesResponse structure. this.VerifyGetSiteTemplates(templateList); return getSiteTemplateResult; }
/// <summary> /// Verify GetSiteTemplates related requirements. /// </summary> /// <param name="templateList">SiteTemplates list.</param> private void VerifyGetSiteTemplates(Template[] templateList) { Site.Log.Add(LogEntryKind.Comment, "Verify common requirements in GetSiteTemplates operation."); this.VerifyCommonReqs(); // When code can run to this line, it indicates the soap out message for this operation is received, else the operation will throw exception above. // So this operation's description is consistent with server. Site.CaptureRequirement( 138, @"[In GetSiteTemplates] [The GetSiteTemplates operation is defined as:] <wsdl:operation name=""GetSiteTemplates""> <wsdl:input message=""tns:GetSiteTemplatesSoapIn"" /> <wsdl:output message=""tns:GetSiteTemplatesSoapOut"" /> </wsdl:operation>"); bool isSchemaRight = SchemaValidation.XmlValidationErrors.Count == 0 && SchemaValidation.XmlValidationWarnings.Count == 0; // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R140. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R140"); // Verify MS-SITESS requirement: MS-SITESS_R140 Site.CaptureRequirementIfIsTrue( isSchemaRight, 140, @"[In GetSiteTemplates] [The client sends a GetSiteTemplatesSoapIn request message and] the server responds with a GetSiteTemplatesSoapOut response message."); // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R146. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R146"); // Verify MS-SITESS requirement: MS-SITESS_R146 Site.CaptureRequirementIfIsTrue( isSchemaRight, 146, @"[In GetSiteTemplatesSoapOut] The SOAP body contains a GetSiteTemplatesResponse element."); // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R151. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R151"); // Verify MS-SITESS requirement: MS-SITESS_R151 Site.CaptureRequirementIfIsTrue( isSchemaRight, 151, @"[In GetSiteTemplatesResponse] [The GetSiteTemplatesResponse element is defined as:] <s:element name=""GetSiteTemplatesResponse""> <s:complexType> <s:sequence> <s:element minOccurs=""1"" maxOccurs=""1"" name=""GetSiteTemplatesResult"" type=""s:unsignedInt"" /> <s:element minOccurs=""0"" maxOccurs=""1"" name=""TemplateList"" type=""tns:ArrayOfTemplate"" /> </s:sequence> </s:complexType> </s:element>"); // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R155. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R155"); // Verify MS-SITESS requirement: MS-SITESS_R155 Site.CaptureRequirementIfIsTrue( isSchemaRight, 155, @"[In GetSiteTemplatesResponse] [TemplateList:] The type of TemplateList is specified in section 3.1.4.5.3.1."); // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R159. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R159"); // Verify MS-SITESS requirement: MS-SITESS_R159 Site.CaptureRequirementIfIsTrue( isSchemaRight, 159, @"[In ArrayOfTemplate] It [the ArrayOfTemplate complex type] contains the element Template, which is defined in section 3.1.4.5.3.2."); // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R160. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R160"); // Verify MS-SITESS requirement: MS-SITESS_R160 Site.CaptureRequirementIfIsTrue( isSchemaRight, 160, @"[In ArrayOfTemplate] [The ArrayOfTemplate complex type is defined as:] <s:complexType name=""ArrayOfTemplate""> <s:sequence> <s:element minOccurs=""0"" maxOccurs=""unbounded"" name=""Template"" nillable=""true"" type=""tns:Template"" /> </s:sequence> </s:complexType>"); // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R163. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R163"); // Verify MS-SITESS requirement: MS-SITESS_R163 Site.CaptureRequirementIfIsTrue( isSchemaRight, 163, @"[In Template] [The Template complex type is defined as:] <s:complexType name=""Template""> <s:attribute name=""ID"" type=""s:int"" use=""required"" /> <s:attribute name=""Title"" type=""s:string"" use=""required"" /> <s:attribute name=""Name"" type=""s:string"" use=""required"" /> <s:attribute name=""IsUnique"" type=""s:boolean"" use=""required"" /> <s:attribute name=""IsHidden"" type=""s:boolean"" use=""required"" /> <s:attribute name=""Description"" type=""s:string"" /> <s:attribute name=""ImageUrl"" type=""s:string"" use=""required"" /> <s:attribute name=""IsCustom"" type=""s:boolean"" use=""required"" /> <s:attribute name=""IsSubWebOnly"" type=""s:boolean"" use=""required"" /> <s:attribute name=""IsRootWebOnly"" type=""s:boolean"" use=""required"" /> <s:attribute name=""DisplayCategory"" type=""s:string"" /> <s:attribute name=""FilterCategories"" type=""s:string"" /> <s:attribute name=""HasProvisionClass"" type=""s:boolean"" use=""required"" /> </s:complexType>"); if (templateList != null) { for (int i = 0; i < templateList.Length; i++) { // Check whether the "Name" consists of string, "#" and number. bool isValidName = Regex.IsMatch(templateList[i].Name, @"^(\w+)#(\d+)$"); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R168, the name of template is {0}", templateList[i].Name); // If "Name" consists of string, "#" and number, then R168 can be verified. // Verify MS-SITESS requirement: MS-SITESS_R168 Site.CaptureRequirementIfIsTrue( isValidName, 168, @"[In Template] [Name:] It contains the name of the site definition followed by a number sign (#), and then the site definition configuration number."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R170, the Template {0} unique.", templateList[i].IsUnique ? "is" : "is not"); // Verify MS-SITESS requirement: MS-SITESS_R170 Site.CaptureRequirementIfIsFalse( templateList[i].IsUnique, 170, @"[In Template] [IsUnique:] It MUST be false when sending[ and ignored on receipt]."); // Specifies whether the ImageUrl is a relative URL. bool isURI = Uri.IsWellFormedUriString(templateList[i].ImageUrl, UriKind.Relative); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R175, the ImageUrl is {0}", templateList[i].ImageUrl); // Verify MS-SITESS requirement: MS-SITESS_R175 Site.CaptureRequirementIfIsTrue( isURI, 175, @"[In Template] [ImageUrl:] It MUST be the URL in relative to the URL of the site."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R177, the value of templateList[{0}].IsCustom is {1}", i, templateList[i].IsCustom); // Verify MS-SITESS requirement: MS-SITESS_R177 Site.CaptureRequirementIfIsTrue( templateList[i].IsCustom, 177, @"[In Template] [IsCustom:] It MUST be true."); } } }