/// <summary> /// A method used to verify field's id or field's type is equal to expected value. /// </summary> /// <param name="responseOfGetList">A parameter represents the response of GetList operation which contains the field definitions.</param> /// <param name="expectedFieldName">A parameter represents the name of a field definition which is used to get the definition from the response of GetList operation.</param> /// <param name="expectedFieldId">A parameter represents the expected id of field definition.</param> /// <param name="expectedFieldType">A parameter represents the expected type of field definition.</param> /// <returns>Return true indicating the verification pass.</returns> private bool VerifyTypeAndIdForFieldDefinition(GetListResponseGetListResult responseOfGetList, string expectedFieldName, string expectedFieldId, string expectedFieldType) { if (string.IsNullOrEmpty(expectedFieldName)) { throw new ArgumentNullException("expectedFieldName"); } // Get the field definition from response. FieldDefinition fieldDefinition = Common.GetFieldItemByName(responseOfGetList, expectedFieldName, this.Site); // Verify field type. this.Site.Assert.IsTrue( Common.VerifyFieldType(fieldDefinition, expectedFieldType, this.Site), @"The field definition's type should match the specified value in protocol."); // Verify field id. this.Site.Assert.IsTrue( Common.VerifyFieldId(fieldDefinition, expectedFieldId, this.Site), @"The field definition's id should match the specified value in protocol."); // If upon verifications pass, return true. return true; }
/// <summary> /// A method used to verify the requirements for common schema definition of list. /// </summary> /// <param name="responseOfGetList">A parameter represents the response of GetList operation which contain common fields' definitions.</param> private void VerifyCommonSchemaOfListDefinition(GetListResponseGetListResult responseOfGetList) { if (null == responseOfGetList) { throw new ArgumentNullException("responseOfGetList"); } // Verify Attachments field's id and type. string actuallistTemplateValue = responseOfGetList.List.ServerTemplate; string docLibraryListTemplateStringValue = ((int)TemplateType.Document_Library).ToString(); if (!docLibraryListTemplateStringValue.Equals(actuallistTemplateValue, StringComparison.OrdinalIgnoreCase)) { bool isVerifyR584 = this.VerifyTypeAndIdForFieldDefinition( responseOfGetList, "Attachments", "{67df98f4-9dec-48ff-a553-29bece9c5bf4}", "Attachments"); // Verify MS-OUTSPS requirement: MS-OUTSPS_R584 this.Site.CaptureRequirementIfIsTrue( isVerifyR584, 584, @"[In Common Schema][One of the common properties appears as the attributes of the element GetListResponse.GetListResult.List.Fields.Field. Field.Name:]Attachments[ Field.ID:]{67df98f4-9dec-48ff-a553-29bece9c5bf4}[Field.Type:]Attachments."); } // Verify ContentTypeId field's id and type. bool isVerifyR586 = this.VerifyTypeAndIdForFieldDefinition( responseOfGetList, "ContentTypeId", "{03e45e84-1992-4d42-9116-26f756012634}", "ContentTypeId"); // Verify MS-OUTSPS requirement: MS-OUTSPS_R586 this.Site.CaptureRequirementIfIsTrue( isVerifyR586, 586, @"[In Common Schema][One of the common properties appears as the attributes of the element GetListResponse.GetListResult.List.Fields.Field. Field.Name:]ContentTypeId[ Field.ID:]{03e45e84-1992-4d42-9116-26f756012634}[Field.Type:]ContentTypeId."); // Verify Created field's id and type. bool isVerifyR587 = this.VerifyTypeAndIdForFieldDefinition( responseOfGetList, "Created", "{8c06beca-0777-48f7-91c7-6da68bc07b69}", "DateTime"); // Verify MS-OUTSPS requirement: MS-OUTSPS_R587 this.Site.CaptureRequirementIfIsTrue( isVerifyR587, 587, @"[In Common Schema][One of the common properties appears as the attributes of the element GetListResponse.GetListResult.List.Fields.Field. Field.Name:]Created[ Field.ID:]{8c06beca-0777-48f7-91c7-6da68bc07b69}[Field.Type:]DateTime."); // Verify ID field's id and type. bool isVerifyR588 = this.VerifyTypeAndIdForFieldDefinition( responseOfGetList, "ID", "{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}", "Counter"); // Verify MS-OUTSPS requirement: MS-OUTSPS_R588 this.Site.CaptureRequirementIfIsTrue( isVerifyR588, 588, @"[In Common Schema][One of the common properties appears as the attributes of the element GetListResponse.GetListResult.List.Fields.Field. Field.Name:]ID[ Field.ID:]{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}[Field.Type:]Counter."); // Verify Modified field's id and type. bool isVerifyR589 = this.VerifyTypeAndIdForFieldDefinition( responseOfGetList, "Modified", "{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}", "DateTime"); // Verify MS-OUTSPS requirement: MS-OUTSPS_R589 this.Site.CaptureRequirementIfIsTrue( isVerifyR589, 589, @"[In Common Schema][One of the common properties appears as the attributes of the element GetListResponse.GetListResult.List.Fields.Field. Field.Name:]Modified[ Field.ID:]{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}[Field.Type:]DateTime."); // Verify owshiddenversion field's id and type. bool isVerifyR590 = this.VerifyTypeAndIdForFieldDefinition( responseOfGetList, "owshiddenversion", "{d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5}", "Integer"); // Verify MS-OUTSPS requirement: MS-OUTSPS_R590 this.Site.CaptureRequirementIfIsTrue( isVerifyR590, 590, @"[In Common Schema][One of the common properties appears as the attributes of the element GetListResponse.GetListResult.List.Fields.Field. Field.Name:]owshiddenversion[ Field.ID:]{d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5}[Field.Type:]Integer."); }
/// <summary> /// Use this method to verify following requirements in multiple operations. /// The names of the attributes containing the list item data in this response correspond /// to the Name attributes in the Field elements of GetList and are prefixed by "ows_". /// </summary> /// <param name="data">The xml Response of the operation that is test</param> /// <param name="list">The xml Response of GetList operation</param> /// <param name="startWithOws">Whether the names have prefix "ows_".</param> /// <param name="correspondNames">Whether the names correspond with the fields in the list.</param> private static void ValidateOwsPrefixAndAttributeName(DataTable data, GetListResponseGetListResult list, out bool startWithOws, out bool correspondNames) { startWithOws = true; correspondNames = true; foreach (DataColumn column in data.Columns) { startWithOws = startWithOws && column.ColumnName.StartsWith(AdapterHelper.PrefixOws, StringComparison.OrdinalIgnoreCase); if (!startWithOws) { break; } } if (startWithOws) { foreach (DataColumn column in data.Columns) { FieldDefinition fd = list.List.Fields.Field.FirstOrDefault<FieldDefinition>(field => AdapterHelper.PrefixOws + field.Name == column.ColumnName); if (fd == null) { correspondNames = false; break; } } } }
/// <summary> /// Verify the message syntax of GetList operation when the response is received /// successfully. /// </summary> /// <param name="getListResult">The returned SOAP result.</param> private void VerifyGetListOperation(GetListResponseGetListResult getListResult) { // Verify R1763 // The response have been received successfully, then the following requirement can be captured. // If the response is not received and parsed successfully, the test case will fail before this requirement is captured Site.CaptureRequirement( 1763, @"[The schema of GetList is defined as:]<wsdl:operation name=""GetList"">" + @" <wsdl:input message=""GetListSoapIn"" />" + @" <wsdl:output message=""GetListSoapOut"" />" + @"</wsdl:operation>"); // Verify R554 // The response have been received successfully, then the following requirement can be captured. // If the response is not received and parsed successfully, the test case will fail before this requirement is captured Site.CaptureRequirement( 554, @"[In GetList operation] [If the protocol client sends a GetListSoapIn request " + "message]The protocol server MUST respond with a GetListSoapOut response " + "message."); // Verify R1768 // The response have been received successfully, then the following requirement can be captured. // If the response is not received and parsed successfully, the test case will fail before this requirement is captured Site.CaptureRequirement( 1768, @"[GetListSoapOut]The SOAP Body contains a GetListResponse element."); // Verify R1771 // The response have been received successfully, then the following requirement can be captured. // If the response is not received and parsed successfully, the test case will fail before this requirement is captured Site.CaptureRequirement( 1771, @"[GetListResponse]<s:element name=""GetListResponse"">" + @" <s:complexType>" + @" <s:sequence>" + @" <s:element name=""GetListResult"" minOccurs=""0"">" + @" <s:complexType mixed=""true"">" + @" <s:sequence>" + @" <s:element name=""List"" type=""tns:ListDefinitionSchema"" />" + @" </s:sequence>" + @" </s:complexType>" + @" </s:element>" + @" </s:sequence>" + @" </s:complexType>" + @"</s:element>"); this.VerifyListDefinitionCT(getListResult.List); // Verify the requirements of the ListDefinitionSchema complex type. if (getListResult.List != null) { this.VerifyListDefinitionSchema(getListResult.List); } }
/// <summary> /// A method used to verify field's id or field's type is equal to expected value. /// </summary> /// <param name="getListResponse">A parameter represents the response of GetList operation which contains the field definitions.</param> /// <param name="fieldName">A parameter represents the name of a field definition which is used to get the definition from the response of GetList operation.</param> /// <param name="expectedFieldId">A parameter represents the expected id of field definition.</param> /// <param name="expectedFieldType">A parameter represents the expected type of field definition.</param> /// <returns>Return true indicating the verification pass.</returns> private bool VerifyFieldTypeAndId(GetListResponseGetListResult getListResponse, string fieldName, string expectedFieldId, string expectedFieldType) { if (string.IsNullOrEmpty(fieldName)) { throw new ArgumentNullException("fieldName"); } // Get the field definition from response. FieldDefinition fieldDefinition = Common.GetFieldItemByName(getListResponse, fieldName, this.Site); // Verify field's type and field's value bool isEqualToExpectedFieldType = false; bool isEqualToExpectedFieldId = false; // Ignore the field type verification if not specified expected value. bool isIgnoreFieldType = string.IsNullOrEmpty(expectedFieldType); if (isIgnoreFieldType) { isEqualToExpectedFieldType = true; } else { isEqualToExpectedFieldType = Common.VerifyFieldType(fieldDefinition, expectedFieldType, this.Site); } // Ignore the field Id verification if not specified expected value. bool isIgnoreFieldId = string.IsNullOrEmpty(expectedFieldId); if (isIgnoreFieldId) { isEqualToExpectedFieldId = true; } else { isEqualToExpectedFieldId = Common.VerifyFieldId(fieldDefinition, expectedFieldId, this.Site); } bool isPassVerification = isEqualToExpectedFieldType && isEqualToExpectedFieldId; // Add logs string verificationMsgOfType = string.Format( "Field type verification perform:[{0}]; actual type value:[{1}], expected value[{2}]", isIgnoreFieldType ? "No" : "Yes", string.IsNullOrEmpty(fieldDefinition.Type) ? @"N/A" : fieldDefinition.Type, isIgnoreFieldType ? @"N/A" : expectedFieldType); string verificationMsgOfId = string.Format( "Field id verification perform:[{0}]; actual id value[{1}], expected value[{2}]", isIgnoreFieldId ? "No" : "Yes", string.IsNullOrEmpty(fieldDefinition.ID) ? @"N/A" : fieldDefinition.ID, isIgnoreFieldId ? @"N/A" : expectedFieldId); this.Site.Log.Add( LogEntryKind.Debug, "Verification detail:\r\n{0}\r\n{1}", verificationMsgOfType, verificationMsgOfId); return isPassVerification; }