Exemplo n.º 1
0
        private static XmlVerifiedQualityCondition CreateVerifiedQualityCondition(
            [NotNull] QualitySpecificationElement element,
            [NotNull] ICollection <XmlIssue> issues,
            [CanBeNull] IQualityConditionExceptionStatistics exceptionStatistics,
            bool reportIssues,
            bool reportParameters,
            bool reportDescription)
        {
            QualityCondition qualityCondition = element.QualityCondition;

            var result =
                new XmlVerifiedQualityCondition
            {
                Name        = Escape(qualityCondition.Name),
                Guid        = qualityCondition.Uuid,
                VersionGuid = qualityCondition.VersionUuid,
                Type        = element.AllowErrors
                                                       ? XmlQualityConditionType.Soft
                                                       : XmlQualityConditionType.Hard,
                StopCondition = element.StopOnError,
                Category      = qualityCondition.Category
            };

            if (issues.Count > 0)
            {
                if (reportIssues)
                {
                    result.AddIssues(issues, element.ReportIndividualErrors);
                }
                else
                {
                    result.IssueCount = issues.Count;
                }
            }

            if (reportParameters)
            {
                result.TestDescriptor = GetTestDescriptor(qualityCondition.TestDescriptor);
                result.AddParameters(GetParameters(qualityCondition));
            }

            if (reportDescription)
            {
                if (StringUtils.IsNotEmpty(qualityCondition.Description))
                {
                    result.Description = Escape(qualityCondition.Description);
                }

                if (StringUtils.IsNotEmpty(qualityCondition.Url))
                {
                    result.Url = Escape(qualityCondition.Url);
                }
            }

            if (exceptionStatistics != null)
            {
                result.ExceptionCount = exceptionStatistics.ExceptionCount;
            }

            return(result);
        }