Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 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++;
 }
Exemplo n.º 3
0
        // 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);
                }
            }
        }
Exemplo n.º 4
0
        /* 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);
        }
Exemplo n.º 5
0
        /* 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));
        }
Exemplo n.º 6
0
 // 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);
     }
 }
Exemplo n.º 7
0
        // 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);
            }
        }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
        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);
                }
            }
        }
Exemplo n.º 10
0
 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);
     }
 }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
 public virtual void wrong(Parse cell)
 {
     cell.addToTag(" bgcolor=\"" + red + "\"");
     cell.body = escape(cell.text());
     counts.wrong++;
 }
Exemplo n.º 13
0
 public virtual void wrong(Parse cell)
 {
     cell.addToTag(" bgcolor=\"" + red + "\"");
     cell.body = escape(cell.text());
     counts.wrong++;
 }
Exemplo n.º 14
0
    public void testText()
    {
        string[] tags ={"td"};
        Parse p = new Parse("<td>a&lt;b</td>", tags);
        Assert.AreEqual("a&lt;b", p.body);
        Assert.AreEqual("a<b", p.text());
        p = new Parse("<td>\ta&gt;b&nbsp;&amp;&nbsp;b>c &&&lt;</td>", tags);
        Assert.AreEqual("a>b & b>c &&<", p.text());
        p = new Parse("<td>\ta&gt;b&nbsp;&amp;&nbsp;b>c &&lt;</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("&nbsp;"));
        Assert.AreEqual("a b", Parse.htmlToText("a <tag /> b"));
        Assert.AreEqual("a", Parse.htmlToText("a &nbsp;"));
        Assert.AreEqual("a", Parse.htmlToText("\u00a0 a \u00a0"));
        Assert.AreEqual("&nbsp;", Parse.htmlToText("&amp;nbsp;"));
        Assert.AreEqual("1     2", Parse.htmlToText("1 &nbsp; &nbsp; 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"));
    }
Exemplo n.º 15
0
 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);
         }
     }
 }
Exemplo n.º 16
0
 // 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);
         }
     }
 }
Exemplo n.º 17
0
 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++;
 }