private List <ReverseCoverageResult> MapUniqueResults(List <ModelValidationResult> validationResults) { var uniqueResults = new List <ReverseCoverageResult>(); foreach (var result in validationResults) { if (!uniqueResults.Any(r => r.Model.GetType() == result.Model.GetType())) { var newResult = new ReverseCoverageResult(); newResult.Model = result.Model; newResult.ModelFullClassName = result.Model.GetType().FullName; newResult.ModelShortClassName = result.Model.GetType().Name; foreach (var propResult in result.Properties) { var newPropResult = new ReverseCoveragePropertyResult(); if (propResult.Src != null) { newPropResult.SrcPropertyName = propResult.Src.Name; newPropResult.SrcPropertyValue = ConvertUtils.ToString(propResult.Src.Value); } if (propResult.Dst != null) { newPropResult.DstPropertyName = propResult.Dst.Name; newPropResult.DstPropertyValue = ConvertUtils.ToString(propResult.Dst.Value); } newPropResult.IsValid = propResult.IsValid; newPropResult.Message = propResult.Message; newResult.Properties.Add(newPropResult); } uniqueResults.Add(newResult); } } uniqueResults = uniqueResults.OrderBy(r => r.Model.GetType().Name) .ToList(); return(uniqueResults); }
private List<ReverseCoverageResult> MapUniqueResults(List<ModelValidationResult> validationResults) { var uniqueResults = new List<ReverseCoverageResult>(); foreach (var result in validationResults) { if (!uniqueResults.Any(r => r.Model.GetType() == result.Model.GetType())) { var newResult = new ReverseCoverageResult(); newResult.Model = result.Model; newResult.ModelFullClassName = result.Model.GetType().FullName; newResult.ModelShortClassName = result.Model.GetType().Name; foreach (var propResult in result.Properties) { var newPropResult = new ReverseCoveragePropertyResult(); if (propResult.Src != null) { newPropResult.SrcPropertyName = propResult.Src.Name; newPropResult.SrcPropertyValue = ConvertUtils.ToString(propResult.Src.Value); } if (propResult.Dst != null) { newPropResult.DstPropertyName = propResult.Dst.Name; newPropResult.DstPropertyValue = ConvertUtils.ToString(propResult.Dst.Value); } newPropResult.IsValid = propResult.IsValid; newPropResult.Message = propResult.Message; newResult.Properties.Add(newPropResult); } uniqueResults.Add(newResult); } } uniqueResults = uniqueResults.OrderBy(r => r.Model.GetType().Name) .ToList(); return uniqueResults; }
private string GenerateDefinitionCoverateTable(ReverseCoverageResult result) { var report = string.Empty; report += "<div>"; report += string.Format("<h4>{0}</h4>", result.ModelShortClassName); report += "<table>"; report += "<thead>"; report += "<td>Property</td>"; report += "<td>Support</td>"; report += "<td>Comments</td>"; report += "</thead>"; report += "<tbody>"; foreach (var propResult in result.Properties.OrderBy(p => { var localPropName = p.SrcPropertyName; if (localPropName.Contains(".")) { localPropName = localPropName.Split('.')[1]; } return(localPropName); })) { var propName = propResult.SrcPropertyName; // method calls, such as 's.Scope.ToString() ' if (propName.Contains(".")) { propName = propName.Split('.')[1]; } report += "<tr>"; report += string.Format("<td>{0}</td>", propName); if (propResult.Message == SkipMessages.NotImplemented) { report += string.Format("<td>{0}</td>", false); report += string.Format("<td>{0}</td>", propResult.Message); } else { report += string.Format("<td>{0}</td>", propResult.IsValid); report += string.Format("<td>{0}</td>", propResult.Message); } report += "</tr>"; } report += "</tbody>"; report += "</table>"; report += "</div>"; return(report); }
private string GenerateDefinitionCoverateTable(ReverseCoverageResult result) { var report = string.Empty; report += "<div>"; report += string.Format("<h4>{0}</h4>", result.ModelShortClassName); report += "<table>"; report += "<thead>"; report += "<td>Property</td>"; report += "<td>Support</td>"; report += "<td>Comments</td>"; report += "</thead>"; report += "<tbody>"; foreach (var propResult in result.Properties.OrderBy(p => { var localPropName = p.SrcPropertyName; if (localPropName.Contains(".")) localPropName = localPropName.Split('.')[1]; return localPropName; })) { var propName = propResult.SrcPropertyName; // method calls, such as 's.Scope.ToString() ' if (propName.Contains(".")) propName = propName.Split('.')[1]; report += "<tr>"; report += string.Format("<td>{0}</td>", propName); if (propResult.Message == SkipMessages.NotImplemented) { report += string.Format("<td>{0}</td>", false); report += string.Format("<td>{0}</td>", propResult.Message); } else { report += string.Format("<td>{0}</td>", propResult.IsValid); report += string.Format("<td>{0}</td>", propResult.Message); } report += "</tr>"; } report += "</tbody>"; report += "</table>"; report += "</div>"; return report; }