void MarkCellWithCounts(ExecuteParameters parameters, TestCounts beforeCounts) { string style = Processor.TestStatus.Counts.Subtract(beforeCounts).Style; if (!string.IsNullOrEmpty(style) && string.IsNullOrEmpty(parameters.Cell.GetAttribute(CellAttribute.Status))) { parameters.Cell.SetAttribute(CellAttribute.Status, style); } }
void Input(ExecuteContext context, ExecuteParameters parameters) { var beforeCounts = new TestCounts(Processor.TestStatus.Counts); Processor.InvokeWithThrow(context.SystemUnderTest, GetMemberName(parameters.Members), new CellTree(parameters.Cells)); MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts)); }
void MarkCellWithLastResults(ExecuteParameters parameters, Action<ExecuteParameters> markWithCounts) { if (parameters.Cells != null && !string.IsNullOrEmpty(Processor.TestStatus.LastAction)) { parameters.Cell.SetAttribute(CellAttribute.Folded, Processor.TestStatus.LastAction); markWithCounts(parameters); } Processor.TestStatus.LastAction = null; }
static void ShowActual(ExecuteParameters parameters, object actual) { parameters.Cell.AddToAttribute( CellAttribute.InformationSuffix, actual == null ? "null" : actual.ToString().Length == 0 ? "blank" : actual.ToString()); }
void Input(ExecuteContext context, ExecuteParameters parameters) { var beforeCounts = new TestCounts(Processor.TestStatus.Counts); Processor.InvokeWithThrow(context.SystemUnderTest, GetMemberName(parameters.Members), new CellTree(parameters.Cells)); MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts)); }
public void LastActionIsSetAsInputCellAttribute() { SetUpSUT("procedure"); var parameters = new ExecuteParameters( ExecuteParameters.MakeMemberCell(new CellTreeLeaf("procedure"), targetCell)); execute.Execute(new ExecuteContext(ExecuteCommand.Input, target.Value), parameters); Assert.AreEqual("blah blah", targetCell.Value.GetAttribute(CellAttribute.Extension)); }
public void LastActionIsSetAsExpectedCellAttribute() { SetUpSUT("procedure"); var parameters = new ExecuteParameters( ExecuteParameters.Make(new CellTreeLeaf("procedure"), new CellTree(), targetCell)); execute.Execute(new ExecuteContext(ExecuteCommand.Check, target.Value), parameters); Assert.AreEqual("blah blah", targetCell.Value.GetAttribute(CellAttribute.Folded)); }
static void ShowActual(ExecuteParameters parameters, object actual) { parameters.Cell.AddToAttribute( CellAttribute.InformationSuffix, actual == null ? "null" : actual.ToString().Length == 0 ? "blank" : actual.ToString()); }
void MarkCellWithLastResults(ExecuteParameters parameters, Action <ExecuteParameters> markWithCounts) { if (parameters.Cells != null && !string.IsNullOrEmpty(Processor.TestStatus.LastAction)) { parameters.Cell.SetAttribute(CellAttribute.Extension, Processor.TestStatus.LastAction); markWithCounts(parameters); } Processor.TestStatus.LastAction = null; }
void MarkCellWithCounts(ExecuteParameters parameters, TestCounts beforeCounts) { string style = Processor.TestStatus.Counts.Subtract(beforeCounts).Style; if (!string.IsNullOrEmpty(style) && string.IsNullOrEmpty(parameters.Cell.GetAttribute(CellAttribute.Status))) { parameters.Cell.SetAttribute(CellAttribute.Status, style); } }
private void EvaluateException(bool expression, ExecuteParameters parameters, TargetInvocationException e) { if (expression) { Processor.TestStatus.MarkRight(parameters.Cell); } else { Processor.TestStatus.MarkWrong(parameters.Cell, "exception[" + e.InnerException.GetType().Name + ": \"" + e.InnerException.Message + "\"]"); } }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { object value = GetActual(context, parameters); var symbol = new Symbol(parameters.Cell.Text.Substring(2), value); Processor.Store(symbol); parameters.Cell.AddToAttribute(CellAttribute.InformationSuffix, value == null ? "null" : value.ToString()); return TypedValue.Void; }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { try { object actual = GetActual(context, parameters); Processor.TestStatus.MarkWrong(parameters.Cell, actual.ToString()); } catch { Processor.TestStatus.MarkRight(parameters.Cell); } return TypedValue.Void; }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { object value = GetActual(context, parameters); var symbol = new Symbol(parameters.Cell.Text.Substring(2), value); Processor.Store(symbol); parameters.Cell.AddToAttribute(CellAttribute.InformationSuffix, value == null ? "null" : value.ToString()); return(TypedValue.Void); }
TypedValue Invoke(ExecuteContext context, ExecuteParameters parameters) { var beforeCounts = new TestCounts(Processor.TestStatus.Counts); TypedValue target = context.Target.Value; var targetObjectProvider = target.Value as TargetObjectProvider; string name = GetMemberName(parameters.Members); TypedValue result = Processor.Invoke( targetObjectProvider != null ? new TypedValue(targetObjectProvider.GetTargetObject()) : target, name, parameters.Parameters); MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts)); return result; }
TypedValue Invoke(ExecuteContext context, ExecuteParameters parameters) { var beforeCounts = new TestCounts(Processor.TestStatus.Counts); TypedValue target = context.Target.Value; var targetObjectProvider = target.Value as TargetObjectProvider; string name = GetMemberName(parameters.Members); TypedValue result = Processor.Invoke( targetObjectProvider != null ? new TypedValue(targetObjectProvider.GetTargetObject()) : target, name, parameters.Parameters); MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts)); return(result); }
void Check(ExecuteContext context, ExecuteParameters parameters) { try { TypedValue actual = GetTypedActual(context, parameters); if (Processor.Compare(actual, parameters.Cells)) { Processor.TestStatus.MarkRight(parameters.Cell); } else { Processor.TestStatus.MarkWrong(parameters.Cell, actual.ValueString); } } catch (IgnoredException) {} MarkCellWithLastResults(parameters, p => {}); }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { switch (context.Command) { case ExecuteCommand.Check: Check(context, parameters); break; case ExecuteCommand.Invoke: return Invoke(context, parameters); default: throw new ArgumentException(string.Format("Unrecognized operation '{0}'", context.Command)); } return TypedValue.Void; }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { switch (context.Command) { case ExecuteCommand.Input: TypedValue actual = Processor.Invoke(context.SystemUnderTest, GetMemberName(parameters.Members), new TreeList<Cell>()); if (actual.IsValid) ShowActual(parameters, actual.Value); break; case ExecuteCommand.Check: ShowActual(parameters, GetActual(context, parameters)); break; } return TypedValue.Void; }
void Check(ExecuteContext context, ExecuteParameters parameters) { try { TypedValue actual = GetTypedActual(context, parameters); if (Processor.Compare(actual, parameters.Cells)) { Processor.TestStatus.MarkRight(parameters.Cell); } else { Processor.TestStatus.MarkWrong(parameters.Cell, actual.ValueString); } } catch (IgnoredException) {} MarkCellWithLastResults(parameters, p => {}); }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { switch (context.Command) { case ExecuteCommand.Input: TypedValue actual = Processor.Invoke(context.SystemUnderTest, GetMemberName(parameters.Members), new CellTree()); if (actual.IsValid) { ShowActual(parameters, actual.Value); } break; case ExecuteCommand.Check: ShowActual(parameters, GetActual(context, parameters)); break; } return(TypedValue.Void); }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { string exceptionContent = parameters.Cell.Text.Substring("exception[".Length, parameters.Cell.Text.Length - ("exception[".Length + 1)); try { GetActual(context, parameters); Processor.TestStatus.MarkWrong(parameters.Cell, "no exception"); } catch (TargetInvocationException e) { if (IsMessageOnly(exceptionContent)) { EvaluateException(e.InnerException.Message == exceptionContent.Substring(1, exceptionContent.Length - 2), parameters, e); } else if (IsExceptionTypeNameOnly(exceptionContent)) { string actual = e.InnerException.GetType().Name + ": \"" + e.InnerException.Message + "\""; EvaluateException(exceptionContent == actual, parameters, e); } else { EvaluateException(e.InnerException.GetType().Name == exceptionContent, parameters, e); } } return TypedValue.Void; }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { switch (context.Command) { case ExecuteCommand.Input: Input(context, parameters); break; case ExecuteCommand.Check: Check(context, parameters); break; case ExecuteCommand.Compare: return(new TypedValue(Processor.Compare(context.Target.Value, parameters.Cells))); case ExecuteCommand.Invoke: return(Invoke(context, parameters)); default: throw new ArgumentException(string.Format("Unrecognized operation '{0}'", context.Command)); } return(TypedValue.Void); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return(context.Command == ExecuteCommand.Check && parameters.Cell.Text.StartsWith(">>")); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return (context.Command == ExecuteCommand.Check || context.Command == ExecuteCommand.Input) && parameters.Cell.Text.Length == 0 && parameters.Cells.IsLeaf; }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return context.Command == ExecuteCommand.Check && parameters.Cell.Text.StartsWith(">>"); }
TypedValue Execute(Tree<Cell> targetCell) { var parameters = new ExecuteParameters( ExecuteParameters.Make(new CellTreeLeaf(memberName), new CellTree(), targetCell)); return execute.Execute(new ExecuteContext(ExecuteCommand.Invoke, target), parameters); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return(context.Command == ExecuteCommand.Check && exceptionIdentifier.IsStartOf(parameters.Cell.Text) && parameters.Cell.Text.EndsWith("]")); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return context.Command == ExecuteCommand.Check && errorIdentifier.Equals(parameters.Cell.Text); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return context.Command == ExecuteCommand.Check && exceptionIdentifier.IsStartOf(parameters.Cell.Text) && parameters.Cell.Text.EndsWith("]"); }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { ShowActual(parameters, GetActual(context, parameters)); return TypedValue.Void; }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return true; }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return(true); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { return((context.Command == ExecuteCommand.Check || context.Command == ExecuteCommand.Input) && parameters.Cell.Text.Length == 0 && parameters.Cells.IsLeaf); }