public override void doCell(Parse cell, int column) { TypeAdapter a = columnBindings[column]; try { string text = cell.text(); if (text == "") { check(cell, a); } else if (a == null) { ignore(cell); } else if (a.field != null) { a.set(a.parse(text)); } else if (a.method != null) { check(cell, a); } } catch (Exception e) { exception(cell, e); } }
public void error(Parse cell, String message) { cell.body = escape(cell.text()); cell.addToBody("<hr><pre>" + escape(message) + "</pre>"); cell.addToTag(" bgcolor=\"" + yellow + "\""); counts.exceptions++; }
// Utility ////////////////////////////////// protected virtual void bind(Parse heads) { columnBindings = new TypeAdapter[heads.size()]; for (int i = 0; heads != null; i++, heads = heads.more) { String name = heads.text(); String suffix = "()"; try { if (name == "") { columnBindings[i] = null; } else if (name.EndsWith(suffix)) { columnBindings[i] = bindMethod(name.Substring(0, name.Length - suffix.Length)); } else { columnBindings[i] = bindField(name); } } catch (Exception e) { exception(heads, e); } } }
/* Added from FitNesse*/ protected Fixture getLinkedFixtureWithArgs(Parse tables) { Parse header = tables.at(0, 0, 0); Fixture fixture = loadFixture(header.text()); fixture.counts = counts; fixture.summary = summary; fixture.getArgsForTable(tables); return(fixture); }
/* Added by Rick Mugridge, from FitNesse */ protected void getArgsForTable(Parse table) { ArrayList argumentList = new ArrayList(); Parse parameters = table.parts.parts.more; for (; parameters != null; parameters = parameters.more) { argumentList.Add(parameters.text()); } args = (String[])argumentList.ToArray(typeof(String)); }
// Traversal //////////////////////////////// public override void doCells(Parse cells) { this.cells = cells; try { MethodInfo action = GetType().GetMethod(cells.text(), new Type[] {}); action.Invoke(this, new Type[] {}); } catch (Exception e) { exception(cells, e); } }
private void systemMethod(string prefix, Parse cell) { string method = camel(prefix+" "+cell.text()); Type[] empty = {}; try { BindingFlags searchFlags = BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public; MethodInfo methodInfo = system.GetType().GetMethod(method, searchFlags, null, empty, null); methodInfo.Invoke(system,empty); } catch (Exception e) { exception (cell, e); } }
public virtual void check(Parse cell, TypeAdapter a) { string text = cell.text(); if (text == "") { try { info(cell, a.ToString(a.get())); } catch (Exception) { info(cell, "error"); } } else if (a == null) { ignore(cell); } else if (text == "error") { try { wrong(cell, a.ToString(a.get())); } catch (MethodAccessException e) { exception(cell, e); } catch (Exception) { right(cell); } } else { try { object result = a.get(); if (a.equals(a.parse(text), result)) { right(cell); } else { wrong(cell, a.ToString(a.get())); } } catch (Exception e) { exception(cell, e); } } }
public override void doCell(Parse cell, int column) { TypeAdapter a = columnBindings[column]; try { string text = cell.text(); if (text == "") { check(cell, a); } else if (a == null) { ignore(cell); } else if (a.field != null) { a.set(a.parse(text)); } else if (a.method != null) { check(cell, a); } } catch(Exception e) { exception(cell, e); } }
protected virtual Hashtable eSort(ArrayList list, int col) { TypeAdapter a = columnBindings[col]; Hashtable result = new Hashtable(); foreach (Parse row in list) { Parse cell = row.parts.at(col); try { object key = a.parse(cell.text()); bin(result, key, row); } catch (Exception e) { exception(cell, e); for (Parse rest = cell.more; rest != null; rest = rest.more) { ignore(rest); } } } return(result); }
public virtual void wrong(Parse cell) { cell.addToTag(" bgcolor=\"" + red + "\""); cell.body = escape(cell.text()); counts.wrong++; }
public void testText() { string[] tags ={"td"}; Parse p = new Parse("<td>a<b</td>", tags); Assert.AreEqual("a<b", p.body); Assert.AreEqual("a<b", p.text()); p = new Parse("<td>\ta>b & b>c &&<</td>", tags); Assert.AreEqual("a>b & b>c &&<", p.text()); p = new Parse("<td>\ta>b & b>c &<</td>", tags); Assert.AreEqual("a>b & b>c &<", p.text()); p = new Parse("<TD><P><FONT FACE=\"Arial\" SIZE=2>GroupTestFixture</FONT></TD>", tags); Assert.AreEqual("GroupTestFixture",p.text()); Assert.AreEqual("", Parse.htmlToText(" ")); Assert.AreEqual("a b", Parse.htmlToText("a <tag /> b")); Assert.AreEqual("a", Parse.htmlToText("a ")); Assert.AreEqual("a", Parse.htmlToText("\u00a0 a \u00a0")); Assert.AreEqual(" ", Parse.htmlToText("&nbsp;")); Assert.AreEqual("1 2", Parse.htmlToText("1 2")); Assert.AreEqual("1 2", Parse.htmlToText("1 \u00a0\u00a0\u00a0\u00a02")); Assert.AreEqual("a", Parse.htmlToText(" <tag />a")); Assert.AreEqual("a\nb", Parse.htmlToText("a<br />b")); Assert.AreEqual("ab", Parse.htmlToText("<font size=+1>a</font>b")); Assert.AreEqual("ab", Parse.htmlToText("a<font size=+1>b</font>")); Assert.AreEqual("a<b", Parse.htmlToText("a<b")); Assert.AreEqual("a\nb\nc\nd", Parse.htmlToText("a<br>b<br/>c< br / >d")); Assert.AreEqual("a\nb", Parse.htmlToText("a</p><p>b")); Assert.AreEqual("a\nb", Parse.htmlToText("a< / p > < p >b")); }
public virtual void check(Parse cell, TypeAdapter a) { string text = cell.text(); if (text == "") { try { info(cell, a.ToString(a.get())); } catch (Exception) { info(cell, "error"); } } else if (a == null) { ignore(cell); } else if (text == "error") { try { wrong(cell, a.ToString(a.get())); } catch (MethodAccessException e) { exception (cell, e); } catch (Exception) { right(cell); } } else { try { object result = a.get(); if (a.equals(a.parse(text), result)) { right(cell); } else { wrong(cell, a.ToString(a.get())); } } catch (Exception e) { exception(cell, e); } } }
// Utility ////////////////////////////////// protected virtual void bind(Parse heads) { columnBindings = new TypeAdapter[heads.size()]; for (int i=0; heads!=null; i++, heads=heads.more) { String name = heads.text(); String suffix = "()"; try { if (name == "") { columnBindings[i] = null; } else if (name.EndsWith(suffix)) { columnBindings[i] = bindMethod(name.Substring(0,name.Length-suffix.Length)); } else { columnBindings[i] = bindField(name); } } catch (Exception e) { exception (heads, e); } } }