/// <summary> /// this simply calls out to the FormattedConstraint class to create a message. It's abstracted to be mockable. /// </summary> /// <param name="tc"></param> /// <returns></returns> internal string GetAssertionTestMessage(TemplateConstraint tc, string conformance = null) { List <string> messages = new List <string>(); IFormattedConstraint currentFc = FormattedConstraintFactory.NewFormattedConstraint(this.rep, this.igSettings, this.igTypePlugin, tc, this.constraintReferences); if (!string.IsNullOrEmpty(conformance)) { currentFc.Conformance = conformance; } // Need to re-parse the properties of the formatted constraint since they have changed currentFc.ParseFormattedConstraint(); messages.Add(currentFc.GetPlainText(false, false, false)); if (tc.IsBranch || tc.IsBranchDescendent()) { foreach (var child in tc.ChildConstraints) { if (child.IsBranchIdentifier) { messages.Add(GetAssertionTestMessage(child)); } } } return(string.Join(" ", messages)); }
internal Conformance GetMinimumConformanceForConstraint(TemplateConstraint aConstraint) { if (aConstraint == null) { return(Conformance.UNKNOWN); } Conformance minLevel = aConstraint.BusinessConformanceType; TemplateConstraint constraint = aConstraint; if (!aConstraint.IsBranchDescendent() || (aConstraint.IsPrimitive && aConstraint.IsSchRooted)) { return(minLevel); } while (constraint != null) { if (minLevel < constraint.BusinessConformanceType) { minLevel = constraint.BusinessConformanceType; } if (constraint.IsBranch) { break; } constraint = constraint.ParentConstraint; } return(minLevel); }
/// <summary> /// Determines if a constraint should be included as an individual assertion, or if it is part of a branched parent constraint and should be ignored. /// </summary> /// <param name="constraint">The constraint in question.</param> /// <returns>True if the constraint should be skipped from generation, false if it should be included.</returns> private bool ShouldSkipConstraint(TemplateConstraint constraint, bool SkipBranchDescendents = false) { bool isAttribute = !string.IsNullOrEmpty(constraint.Context) && constraint.Context.StartsWith("@"); bool shouldSkip = constraint.IsBranchIdentifier && string.IsNullOrEmpty(constraint.Schematron); if (SkipBranchDescendents) //should we exclude all descendents of a branch { // Skip for constraints that are rooted, but only when there is either custom schematron or it is a primitive bool isSchRooted = constraint.IsSchRooted && (!string.IsNullOrEmpty(constraint.Schematron) || constraint.IsPrimitive); if (!shouldSkip && !isSchRooted) { shouldSkip = constraint.IsBranchDescendent(); } } return(shouldSkip); }