/// /// <summary> * Evaluates the boolean expression (child Term element) if it fits the /// * JDFNode 'jdf' a value of true corresponds to a failed test, i.e. the test /// * describes INVALID states for the jdf /// * </summary> /// * <param name="jdf"> /// * JDFNode to test to know if the Device can accept it </param> /// * <param name="reportRoot"> /// * the report to generate. Set to <code>null</code> if no report /// * is requested. </param> /// * <returns> boolean - true, if boolean expression (child Term element) /// * evaluates to “true” </returns> /// public override bool fitsJDF(KElement jdf, KElement reportRoot) { KElement reportRootLocal = reportRoot; if (reportRootLocal != null) { reportRootLocal = reportRootLocal.appendElement("TestReport"); } JDFTerm t = getTerm(); if (t == null) { return(true); // no term --> assume it is a non test; i.e. ok } bool checkContext = true; if (hasAttribute(AttributeName.CONTEXT)) { checkContext = !jdf.matchesPath(getContext(), true); } if (checkContext && !t.fitsContext(jdf)) { return(true); } bool b = t.fitsJDF(jdf, reportRootLocal); if (reportRootLocal != null) { reportRootLocal.setAttribute("Value", b, null); } return(b); }
/// /// <summary> * check whether the boolean logic defined by a Test and a test's /// * subelements make sense in the context of the tested element jdf </summary> /// public override bool fitsContext(KElement testElement) { // we only want the leaves as of now if (testElement is JDFResource) { JDFResource r = (JDFResource)testElement; if (!r.isLeaf()) { return(false); } } VElement v = getTermVector(null); int siz = v.Count; for (int i = 0; i < siz; i++) { JDFTerm t = (JDFTerm)v[i]; if (!t.fitsContext(testElement)) // one bad context spoils the // barrell { return(false); } } return(siz > 0); // if no subelements, then no context }