public virtual void testStateReportRequired() { JDFDoc d = new JDFDoc("DevCap"); JDFDevCap dc = (JDFDevCap)d.getRoot(); dc.setName("foo"); JDFIntegerState @is = dc.appendIntegerState(); @is.setName("bar1"); @is.setRequired(true); JDFIntegerState is2 = dc.appendIntegerState(); is2.setName("bar2"); is2.setRequired(false); JDFDoc d2 = new JDFDoc("foo"); KElement foo = d2.getRoot(); JDFDoc d3 = new JDFDoc("parent"); KElement parent = d3.getRoot(); dc.stateReport(foo, EnumFitsValue.Allowed, EnumValidationLevel.Complete, false, true, parent); Assert.IsTrue(parent.ToString().IndexOf("bar1") >= 0); Assert.IsFalse(parent.ToString().IndexOf("bar2") >= 0); }
/// /// <summary> * very simple check for the string "snafu" </summary> /// public virtual bool validate(KElement toCheck, KElement report) { bool b = toCheck.ToString().ToUpper().IndexOf("SNAFU") >= 0; if (b) { report.setAttribute("IsValid", false, null); report.setAttribute("ErrorType", "PrivateValidation", null); report.setAttribute("Message", "MyValid: Element contains snafu!!!", null); Console.WriteLine("MyValid: Element contains snafu!!! " + toCheck.Name); } return(!b); }
public virtual void testBadResLink() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType(EnumType.Stitching); JDFResource r = n.addResource(ElementName.STITCHINGPARAMS, EnumUsage.Input); JDFResourceLink rl = n.getLink(r, null); Assert.IsTrue(rl.isValid(EnumValidationLevel.Complete)); Assert.IsTrue(n.isValid(EnumValidationLevel.Incomplete)); rl.setrRef("badLink"); Assert.IsFalse(rl.isValid(EnumValidationLevel.Complete)); Assert.IsFalse(n.isValid(EnumValidationLevel.Complete)); JDFValidator cj = new JDFValidator(); XMLDoc res = cj.processSingleDocument(d); KElement root = res.getRoot(); string s = root.ToString(); Assert.IsTrue(s.IndexOf("Dangling") > 0); }