// // // // Factory ////////////////////////////////// // public static TypeAdapter on(Fixture target, Type type) { TypeAdapter adapter = new TypeAdapter(); adapter.fixture = target; adapter.target = target; adapter.type = type; return adapter; }
public override void Set(Fixture fixture, object value) { if (ParameterDirection.Input.Equals(dbp.Direction) || ParameterDirection.InputOutput.Equals(dbp.Direction)) dbp.Value = value==null?DBNull.Value:value; else throw new NotSupportedException("Cannot use output parameters as input values. Did you forget a question mark after " + dbp.ParameterName); }
public override bool HandleEvaluate(Fixture fixture, Parse cell, Accessor accessor) { object actual=GetActual(accessor, fixture); if (actual==null) return false; String cellText=cell.Text; String expected = cellText.Substring(1, cellText.Length - 2); // Console.WriteLine( // ("[" + cellText + "][" + expected + "][" + actual + "]").Replace(" ","x") // ); return expected.Equals(actual); }
public override object Get(Fixture fixture) { if (ParameterDirection.Input.Equals(dbp.Direction)) throw new NotSupportedException("Cannot use input parameters as output values. Please remove the question mark after " + dbp.ParameterName); if (typeof(DataTable).Equals(dotNetType) && (dbp.Value is DbDataReader)) { DataTable dt=new DataTable(); dt.Load((DbDataReader) dbp.Value); return dt; } //Console.Write("Reading value of "+dbp.DbType+" " +dbp.ParameterName + " = " + dbp.Value+"\n"); return dbp.Value; }
public override bool HandleEvaluate(Fixture fixture, Parse cell, Accessor accessor) { object actual=GetActual(accessor, fixture); if (actual== null) return false; byte[] actbyte = (byte[]) actual; byte[] expected=ParseArray(cell.Text); if (actbyte.Length!=expected.Length) return false; for (int i=0; i<actbyte.Length; i++) if (actbyte[i]!=expected[i]) return false; return true; }
public String Output() { Parse parse = new Parse(OriginalHTML, new String[] {"td"}); Fixture testbed = new Fixture(); if (Annotation.Equals("right")) testbed.right(parse); if (Annotation.Equals("wrong")) testbed.wrong(parse, Text); if (Annotation.Equals("error")) testbed.error(parse, Text); if (Annotation.Equals("info")) testbed.info(parse, Text); if (Annotation.Equals("ignore")) testbed.ignore(parse); return GenerateOutput(parse); }
public override void HandleCheck(Fixture fixture, Parse cell, Accessor accessor) { string expected = cell.Text.Substring("fail[".Length, cell.Text.Length - ("fail[".Length + 1)); Parse newCell = new Parse("td", expected, null, null); ICellHandler handler = CellOperation.GetHandler(fixture, newCell, accessor.ParameterType); if (handler.HandleEvaluate(fixture, newCell, accessor)) { fixture.Wrong(cell); } else { fixture.Right(cell); } }
protected void run(string file, int right, int wrong, int ignores, int exceptions) { string root = findRoot(file); string input = readExample(root + file); Fixture fixture = new Fixture(); Fixture.assemblyDirs = new string[] {".", @"..\..\..\eg\bin\Debug"}; Parse tables; if (input.IndexOf("<wiki>") >= 0) { tables = new Parse(input, new String[]{"wiki", "table", "tr", "td"}); fixture.doTables(tables.parts); } else { tables = new Parse(input, new String[]{"table", "tr", "td"}); fixture.doTables(tables); } StringWriter output = new StringWriter(); tables.print(output); output.Close(); Assert.AreEqual(right, fixture.counts.right, file+" right"); Assert.AreEqual(wrong, fixture.counts.wrong, file+" wrong"); Assert.AreEqual(ignores, fixture.counts.ignores, file+" ignores"); Assert.AreEqual(exceptions, fixture.counts.exceptions, file+" exceptions"); }
// Actions ////////////////////////////////// public virtual void start() { actor = loadFixture(cells.more.text()); }
public override void HandleInput(Fixture fixture, Parse cell, Accessor accessor) { String cellText=cell.Text; String actual= cellText.Substring(1, cellText.Length - 2); accessor.Set(fixture,actual); }
public static TypeAdapter on(Fixture target, MethodInfo method) { TypeAdapter adapter = on(target, method.ReturnType); adapter.method = method; return adapter; }
public void Prepare(Interpreter parent, Tree<Cell> table) { var parentFixture = (Fixture) parent; Processor = parentFixture.Processor; myParentFixture = parentFixture; GetArgsForRow(table.Branches[0]); }
public static TypeAdapter on(Fixture target, FieldInfo field) { TypeAdapter adapter = on(target, field.FieldType); adapter.field = field; return adapter; }
public override void HandleInput(Fixture fixture, Parse cell, Accessor accessor) { accessor.Set(fixture,ParseArray(cell.Text)); }
protected internal Dialog(string message, Fixture caller) { this.messageVar = message; this.caller = caller; }
public override void Set(Fixture fixture, object value) { throw new NotSupportedException("data columns are read only"); }
public override object Get(Fixture fixture) { DataRow dr = (DataRow)fixture.GetTargetObject(); return GetValue(dr, column); }