public override void DoRow(Parse row) { if (row.Parts.Size != rowWidth) { TestStatus.MarkException(row.Parts, new RowWidthException(rowWidth)); } else { try { TypedValue result = CellOperation.Invoke(this, memberNameCells, valueCells.GetCells(new CellRange(row.Parts).Cells), row.Parts); if (result.Type != typeof(bool)) { throw new InvalidMethodException(string.Format("Method does not return boolean.")); } if (result.GetValue <bool>() == expectedCondition) { TestStatus.MarkRight(row); } else { TestStatus.MarkWrong(row); } } catch (ParseException <Cell> e) { TestStatus.MarkException(e.Subject, e.InnerException); } } }
public void DoCheckOperation(Parse expectedValue, CellRange cells) { CellOperation.Check(GetTargetObject(), new CellRange(MethodCells(cells)), new CellRange(ParameterCells(cells)), expectedValue); }
public override void DoRow(Parse theRow) { if (theRow.Parts.More.Size != firstRowCells.Size) { TestStatus.MarkException(theRow.Parts, new RowWidthException(firstRowCells.Size)); return; } Parse headerCell = firstRowCells; foreach (Parse expectedValueCell in new CellRange(theRow.Parts.More).Cells) { try { CellOperation.Check(GetTargetObject(), combineMember, new CellTree(theRow.Parts, headerCell), expectedValueCell); } catch (IgnoredException) { TestStatus.MarkIgnore(expectedValueCell); } catch (Exception e) { TestStatus.MarkException(expectedValueCell, e); } headerCell = headerCell.More; } }
public void DoCheckOperation(Parse expectedValue, CellRange cells) { CellOperation.Check(GetTargetObject(), MethodRowSelector.SelectMethodCells(cells), MethodRowSelector.SelectParameterCells(cells), expectedValue); }
private void RunRow(Parse row) { Parse cell = row.Parts; //first set input params for (int col = 0; col < columnAccessors.Length; col++) { Accessor accessor = columnAccessors[col]; ICellHandler cellHandler = CellOperation.GetHandler(this, cell, accessor.ParameterType); if (!isOutputColumn[col]) { cellHandler.HandleInput(this, cell, accessor); } cell = cell.More; } command.ExecuteNonQuery(); cell = row.Parts; //next evaluate output params for (int col = 0; col < columnAccessors.Length; col++) { Accessor accessor = columnAccessors[col]; ICellHandler cellHandler = CellOperation.GetHandler(this, cell, accessor.ParameterType); if (isOutputColumn[col]) { cellHandler.HandleCheck(this, cell, accessor); } cell = cell.More; } }
public static TypedValue Invoke(this CellOperation operation, object target, Tree <Cell> memberName, Tree <Cell> parameters, Tree <Cell> targetCell) { TypedValue result = operation.TryInvoke(target, memberName, parameters, targetCell); result.ThrowExceptionIfNotValid(); return(result); }
private void CheckRow(Parse row) { Parse cell = row.Parts; //first set input params foreach (DbParameterAccessor accessor in accessors) { ICellHandler cellHandler = CellOperation.GetHandler(this, cell, accessor.ParameterType); if (!accessor.IsBoundToCheckOperation) { cellHandler.HandleInput(this, cell, accessor); } cell = cell.More; } if (expectException) { try { command.ExecuteNonQuery(); Wrong(row); } catch (Exception e) { row.Parts.Last.More = new Parse("td", Gray(e.ToString()), null, null); if (errorCode.HasValue) { if (this.dbEnvironment.GetExceptionCode(e) == errorCode) { Right(row); } else { Wrong(row); } } else { Right(row); } } } else { command.ExecuteNonQuery(); //evaluate output params cell = row.Parts; foreach (DbParameterAccessor accessor in accessors) { ICellHandler cellHandler = CellOperation.GetHandler(this, cell, accessor.ParameterType); if (accessor.IsBoundToCheckOperation) { cellHandler.HandleCheck(this, cell, accessor); } cell = cell.More; } } }
// Actions ////////////////////////////////// public virtual void Start() { actor = CellOperation.Create(cells.More.Text.Trim()).Value; var fixture = actor as Fixture; if (fixture != null) { fixture.Processor = Processor; } }
private void RunRow(Parse row) { Parse cell = row.Parts; //first set input params foreach (DbParameterAccessor accessor in columnBindings) { ICellHandler cellHandler = CellOperation.GetHandler(this, cell, accessor.ParameterType); cellHandler.HandleInput(this, cell, accessor); cell = cell.More; } command.ExecuteNonQuery(); }
public object ExecuteEmbeddedMethod(Parse theCells) { try { CellRange cells = CellRange.GetMethodCellRange(theCells, 0); return (CellOperation.Invoke(this, new CellRange(MethodCells(cells)), new CellRange(ParameterCells(cells)), theCells.More). Value); } catch (ParseException <Cell> e) { TestStatus.MarkException(e.Subject, e.InnerException); throw new IgnoredException(); } }
// Traversal //////////////////////////////// public override void DoCells(Parse cells) { this.cells = cells; try { targetObject = this; CellOperation.Invoke(this, cells); targetObject = actor; } catch (Exception e) { TestStatus.MarkException(cells, e); } }
private void CheckMatchingRow(Parse row, DataRow d) { SetTargetObject(d); Parse cell = row.Parts; foreach (Accessor accessor in accessors) { ICellHandler cellHandler = CellOperation.GetHandler(this, cell, accessor.ParameterType); cellHandler.HandleCheck(this, cell, accessor); cell = cell.More; } }
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); } }
private bool IsMatch(Parse row, DataRow d) { SetTargetObject(d); Parse cell = row.Parts; foreach (DataColumnAccessor accessor in accessors) { ICellHandler cellHandler = CellOperation.GetHandler(this, cell, accessor.ParameterType); if (accessor.IsUsedForMatching() && (!cellHandler.HandleEvaluate(this, cell, accessor))) { return(false); } cell = cell.More; } return(true); }
public override void DoRow(Parse theRow) { try { if (theRow.Parts.Size != headerCells.Size) { throw new FitFailureException(String.Format("Row should be {0} cells wide.", headerCells.Size)); } CellOperation.Invoke(this, new CellRange(headerCells), new CellRange(theRow.Parts), theRow.Parts); } catch (MemberMissingException e) { TestStatus.MarkException(headerCells, e); throw new IgnoredException(); } catch (Exception e) { TestStatus.MarkException(theRow.Parts, e); } }
public string MatchesActualTypeActualValueExpectedValue( string theActualType, string theActualValue, string theExpectedValue) { string expectedValue = theExpectedValue.StartsWith("'") ? theExpectedValue.Substring(1, theExpectedValue.Length - 2) : theExpectedValue; try { string html = "<table><tr><td>" + HttpUtility.HtmlEncode(expectedValue) + "</td></tr></table>"; myCell = Parse.ParseFrom(html).Parts.Parts; return (CellOperation.Compare(MakeTypedValue(theActualValue, theActualType), myCell).ToString()); } catch (Exception) { return("Exception"); } }
public override void DoRow(Parse row) { string memberName = "!" + Processor.ParseTree <Cell, MemberName>(headerRow.Parts.Last); var parameterList = new List <Tree <Cell> >(); Parse nameCell = headerRow.Parts; Parse valueCell = row.Parts; for (int i = 0; i < headerRow.Parts.Size - 1; i++, nameCell = nameCell.More, valueCell = valueCell.More) { parameterList.Add(new CellTreeLeaf(new GracefulName(nameCell.Text).ToString())); parameterList.Add(valueCell); } var result = Processor.InvokeWithThrow(new TypedValue(SystemUnderTest), memberName, new EnumeratedTree <Cell>(parameterList)); CellOperation.Check(SystemUnderTest, result, row.Parts.Last); }
void AddSurplusRow(Parse rows, object extraObject) { Parse cell = null; SetTargetObject(extraObject); foreach (Parse headerCell in new CellRange(headerCells).Cells) { TypedValue actual = CellOperation.Invoke(this, headerCell); var newCell = (Parse)Processor.Compose(actual.Value ?? "null"); if (cell == null) { cell = newCell; } else { cell.Last.More = newCell; } } AddRowToTable(cell, rows); MarkRowAsSurplus(rows.Last); }
void EvaluateCellsInMatchingRow(Parse row, object match) { SetTargetObject(match); Parse cell = row.Parts; foreach (Parse headerCell in new CellRange(headerCells).Cells) { if (cell == null) { cell = new Parse("td", Label("missing"), null, null); TestStatus.MarkWrong(cell); row.Parts.Last.More = cell; } else { CheckCalled(); CellOperation.Check(GetTargetObject(), headerCell, cell); } cell = cell.More; } }
public override void DoRow(Parse theRow) { try { CheckRowSize(theRow.Parts); for (int j = 0; j < expectedCount; j++) { var memberCells = new List <Parse> { headerCells.At(j) }; foreach (Parse cell in methodSuffixCells.Cells) { memberCells.Add(cell); } Parse expectedCell = theRow.Parts.At(myParameterCount + j + 1); try { CellOperation.Check(GetTargetObject(), new CellRange(memberCells), myValues.GetCells(new CellRange(theRow.Parts, myParameterCount).Cells), expectedCell); } catch (MemberMissingException e) { TestStatus.MarkException(headerCells.At(j), e); TestStatus.MarkIgnore(expectedCell); } catch (IgnoredException) { TestStatus.MarkIgnore(expectedCell); } catch (Exception e) { TestStatus.MarkException(expectedCell, e); } } } catch (Exception e) { TestStatus.MarkException(theRow.Parts, e); } }
public CheckBinding(CellOperation operation, TargetObjectProvider targetProvider, Tree<Cell> memberCell) { this.operation = operation; this.memberCell = memberCell; this.targetProvider = targetProvider; }
protected void ProcessFlowRow(Parse theCurrentRow) { try { string specialActionName = RuntimeDirect.MakeDirect( Processor.ParseTree <Cell, MemberName>(new CellRange(theCurrentRow.Parts, 1)).ToString()); TypedValue result = Processor.Invoke(new FlowKeywords(this), specialActionName, theCurrentRow.Parts); if (!result.IsValid) { result = Processor.Invoke(this, specialActionName, theCurrentRow.Parts); } if (!result.IsValid) { result = CellOperation.TryInvoke(this, new CellRange(MethodCells(new CellRange(theCurrentRow.Parts))), new CellRange(ParameterCells(new CellRange(theCurrentRow.Parts))), theCurrentRow.Parts); } if (!result.IsValid) { if (theCurrentRow.Parts.Text.Length > 0) { var newFixture = Processor.ParseTree <Cell, Interpreter>(theCurrentRow); var adapter = newFixture as MutableDomainAdapter; if (adapter != null) { adapter.SetSystemUnderTest(SystemUnderTest); } ProcessRestOfTable(newFixture, theCurrentRow); IHaveFinishedTable = true; } else { result.ThrowExceptionIfNotValid(); } } else { if (TestStatus.IsAbandoned) { TestStatus.MarkIgnore(theCurrentRow); return; } object wrapResult = FixtureResult.Wrap(result.Value); if (wrapResult is bool) { ColorMethodName(theCurrentRow.Parts, (bool)wrapResult); } else if (wrapResult is Fixture) { ProcessRestOfTable((Fixture)wrapResult, theCurrentRow); IHaveFinishedTable = true; return; } } } catch (IgnoredException) {} catch (ParseException <Cell> e) { TestStatus.MarkException(e.Subject, e); IHaveFinishedTable = true; } catch (Exception e) { TestStatus.MarkException(theCurrentRow.Parts, e); IHaveFinishedTable = true; } }
public virtual void Press() { CellOperation.Invoke(actor, cells.More, new CellTree(), cells.More); }
public virtual void Check() { CellOperation.Check(GetTarget(actor), cells.More, cells.More.More); }
public static void Create(this CellOperation operation, MutableDomainAdapter adapter, string className, Tree <Cell> parameterCell) { TypedValue instance = operation.Create(className, parameterCell); adapter.SetSystemUnderTest(instance.Value); }
public CheckBinding(CellOperation operation, object target, Tree<Cell> memberCell) { this.operation = operation; this.memberCell = memberCell; this.target = target; }
public CreateBinding(CellOperation operation, MutableDomainAdapter adapter, string memberName) { this.operation = operation; this.adapter = adapter; this.memberName = memberName; }
public static void Check(this CellOperation operation, object systemUnderTest, Tree <Cell> memberName, Tree <Cell> expectedCell) { operation.Check(systemUnderTest, memberName, new CellTree(), expectedCell); }
public static TypedValue TryInvoke(this CellOperation operation, object target, Tree <Cell> memberName, Tree <Cell> parameters) { return(operation.TryInvoke(target, memberName, parameters, null)); }
public static TypedValue TryInvoke(this CellOperation operation, object target, Tree <Cell> memberName) { return(operation.TryInvoke(target, memberName, new CellTree())); }
bool IsMatch(Parse row, int col) { TypedValue actual = CellOperation.Invoke(this, headerCells.At(col)); return(CellOperation.Compare(actual, GetCellForColumn(row, col))); }
public static TypedValue Create(this CellOperation operation, string className) { return(operation.Create(className, new CellTree())); }