public TypedValue[] ActualValues(CellProcessor processor, object theActualRow) { var actuals = (object[]) theActualRow; var result = new TypedValue[actuals.Length]; for (int i = 0; i < actuals.Length; i++) result[i] = new TypedValue(actuals[i]); return result; }
public TypedValue[] ActualValues(CellProcessor processor, object theActualRow) { if (myColumnsUsed == null) myColumnsUsed = new bool[myHeaderRow.Parts.Size]; var result = new TypedValue[myHeaderRow.Parts.Size]; int column = 0; foreach (Parse headerCell in new CellRange(myHeaderRow.Parts).Cells) { TypedValue memberResult = new CellOperationImpl(processor).TryInvoke(theActualRow, headerCell); if (memberResult.IsValid) { result[column] = memberResult; myColumnsUsed[column] = true; } else { TypedValue itemResult = new CellOperationImpl(processor).TryInvoke(theActualRow, new StringCellLeaf("getitem"), new CellRange(headerCell, 1)); if (itemResult.IsValid) { result[column] = itemResult; myColumnsUsed[column] = true; } else { result[column] = TypedValue.Void; } } column++; } return result; }
public object Evaluate(DomainAdapter theFixture, CellProcessor processor) { cells.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword); var cellCount = cells.Branches.Count; if (cellCount < 2) throw MakeException("missing cells"); var identifier = cells.ValueAt(1).Text; if (newIdentifier.Equals(identifier)) { cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword); return new MethodPhrase(cells.Skip(1)).EvaluateNew(processor); } if (typeIdentifier.Equals(identifier)) { cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword); if (cellCount < 3) throw MakeException("missing cells"); cells.ValueAt(2).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxSUT); return processor.ParseTree(typeof (Type), cells.Branches[2]).Value; } if (currentIdentifier.Equals(identifier)) { cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword); return theFixture.SystemUnderTest; } var fixture = theFixture as FlowInterpreter; if (fixture == null) throw MakeException("flow fixture required"); return processor.Get<Symbols>().HasValue(identifier) ? processor.Get<Symbols>().GetValue(identifier) : fixture.ExecuteFlowRowMethod(processor, cells); }
public void Interpret(CellProcessor processor, Tree<Cell> table) { new Traverse<Cell>() .Rows.First(row => selectValue = new ValuePhrase(row).Evaluate(processor)) .Rows.All(row => SelectRow(processor, row)) .VisitTable(table); }
public static void Evaluate(this Tree<Cell> row, CellProcessor processor) { var interpreter = processor.CallStack.DomainAdapter.GetValueAs<FlowInterpreter>(); if (!row.InvokeSpecialAction(processor, interpreter).IsValid) { row.ExecuteMethod(processor, interpreter); } }
public SocketServer(FitSocket socket, CellProcessor service, ProgressReporter reporter, bool suiteSetUpIsAnonymous) { this.service = service; this.reporter = reporter; this.socket = socket; IMaybeProcessingSuiteSetup = suiteSetUpIsAnonymous; }
public static void DoTable(Tree<Cell> table, Interpreter activeFixture, CellProcessor processor, bool inFlow) { var activeFlowFixture = activeFixture as FlowInterpreter; if (activeFlowFixture != null) activeFlowFixture.DoSetUp(processor, table); activeFixture.Interpret(processor, table); if (activeFlowFixture != null && !inFlow) activeFlowFixture.DoTearDown(table); }
public void Interpret(CellProcessor processor, Tree<Cell> table) { new Traverse<Cell>() .Rows.Header(row => headerRow = row) .Rows.Rest(row => ComputeRow(processor, row)) .VisitTable(table); }
static Interpreter GetNamedFixture(CellProcessor processor, string theName) { if (!processor.Get<Symbols>().HasValue(theName)) return null; var result = processor.Operate<WrapOperator>(new TypedValue(processor.Get<Symbols>().GetValue(theName))); result.AsNot<Interpreter>(() => { throw new FitFailureException("Result is not a Fixture."); }); return result.GetValueAs<Interpreter>(); }
public object EvaluateNew(CellProcessor processor) { if (cells.Branches.Count < 2) throw MakeException("missing cells"); return processor.Create( cells.ValueAt(1).Text, cells.Skip(2)) .Value; }
public InvokeOperation(CellProcessor processor, TypedValue target, Tree<Cell> member, Tree<Cell> parameters, Tree<Cell> cells) { this.processor = processor; Target = target; Member = member; Parameters = parameters; Cells = cells; }
public static TypedValue ExecuteMethod(this Tree<Cell> row, CellProcessor processor, MethodRowSelector selector, object target) { return processor.Execute(target, selector.SelectMethodCells(row), selector.SelectParameterCells(row), row.ValueAt(0)); }
static void Execute(CellProcessor processor, object facility, Tree<Cell> currentRow) { var selector = new DoRowSelector(); var result = processor.ExecuteWithThrow(facility, selector.SelectMethodCells(currentRow), selector.SelectParameterCells(currentRow), currentRow.ValueAt(0)); if (result.IsVoid) return; currentRow.ValueAt(0).SetAttribute(CellAttribute.Folded, result.ValueString); }
private void RunTest(CellProcessor service, string tables) { var socket = new TestSocket(); socket.PutByteString(Protocol.FormatInteger(tables.Length)); socket.PutByteString(tables); socket.PutByteString(Protocol.FormatInteger(0)); var server = new SocketServer(new FitSocket(socket, new NullReporter()), service, new NullReporter(), false); server.ProcessTestDocuments(new StoryTestStringWriter(service).ForTables(s => resultTables += s)); Assert.IsFalse(socket.isOpen); }
public void Interpret(CellProcessor processor, Tree<Cell> table) { var action = new IncludeAction(processor); var currentRow = table.Branches[0].Skip(1); var selector = new SequenceRowSelector(); processor.ExecuteWithThrow(action, selector.SelectMethodCells(currentRow), selector.SelectParameterCells(currentRow), currentRow.ValueAt(0)); table.ValueAt(0, 0).SetAttribute(CellAttribute.Folded, action.Result); }
public TypedValue DoInvoke(CellProcessor processor) { var targetInstance = new TypedValue(target); var targetObjectProvider = target as TargetObjectProvider; var name = GetMemberName(processor); return processor.Invoke( targetObjectProvider != null ? new TypedValue(targetObjectProvider.GetTargetObject()) : targetInstance, name, parameters); }
public void Interpret(CellProcessor processor, Tree<Cell> table) { var firstRow = table.Branches[0]; if (firstRow.Branches.Count < 2) throw new TableStructureException("Missing cells for use."); var fixtureName = firstRow.ValueAt(1).Text; var targetFixture = GetNamedFixture(processor, fixtureName) ?? MakeNewFixture(processor, firstRow); targetFixture.Interpret(processor, table); }
void SelectRow(CellProcessor processor, Tree<Cell> row) { if (processor.Compare(new TypedValue(selectValue), row.Branches[0])) { var interpreter = processor.CallStack.DomainAdapter.GetValueAs<FlowInterpreter>(); new FlowRow(new CellTree(row.Branches.Skip(1))).Evaluate(processor, interpreter); } else { row.Value.SetAttribute(CellAttribute.Status, TestStatus.Ignore); } }
static Interpreter MakeNewFixture(CellProcessor processor, Tree<Cell> firstRow) { var fixture = processor.ParseTree<Cell, Interpreter>(firstRow.Skip(1)); if (firstRow.Branches.Count > 2) { var adapter = fixture as MutableDomainAdapter; if (adapter != null) { var parent = processor.CallStack.DomainAdapter.GetValueAs<DomainAdapter>(); adapter.SetSystemUnderTest(new MethodPhrase(firstRow.Skip(2)).Evaluate(parent, processor)); } } return fixture; }
public static object ExecuteFlowRowMethod(this FlowInterpreter interpreter, CellProcessor processor, Tree<Cell> row) { try { var cells = row.Skip(1); return cells.ExecuteMethod(processor, interpreter).ThrowExceptionIfNotValid().Value; } catch (ParseException<Cell> e) { processor.TestStatus.MarkException(e.Subject, e.InnerException); throw new IgnoredException(); } }
public void Interpret(CellProcessor processor, Tree<Cell> table) { processor.TestStatus.TableCount--; TypedValue result = processor.Invoke( new TypedValue(processor.Configuration.GetItem(table.Branches[0].Branches[1].Value.Text)), table.Branches[0].Branches[2].Value.Text, new CellTree()); result.ThrowExceptionIfNotValid(); if (result.IsVoid) return; table.Branches[0].Branches[2].Value.SetAttribute(CellAttribute.Folded, result.ValueString); }
void ComputeRow(CellProcessor processor, Tree<Cell> row) { var memberName = processor.ParseTree<Cell, MemberName>(headerRow.Branches.Last()).WithNamedParameters(); var parameterList = new List<Tree<Cell>>(); for (var i = 0; i < headerRow.Branches.Count - 1; i++) { parameterList.Add(new CellTreeLeaf(new GracefulName(headerRow.ValueAt(i).Text).ToString())); parameterList.Add(row.Branches[i]); } var result = processor.Invoke(processor.CallStack.DomainAdapter, memberName, new EnumeratedTree<Cell>(parameterList)); processor.Check(result, row.Branches.Last()); }
void ComputeRow(CellProcessor processor, Tree<Cell> row) { var memberName = MemberName.NamedParameterPrefix + processor.ParseTree<Cell, MemberName>(headerRow.Branches.Last()); var parameterList = new List<Tree<Cell>>(); for (var i = 0; i < headerRow.Branches.Count - 1; i++) { parameterList.Add(new CellTreeLeaf(new GracefulName(headerRow.Branches[i].Value.Text).ToString())); parameterList.Add(row.Branches[i]); } var result = processor.Invoke(new TypedValue(SystemUnderTest), memberName, new EnumeratedTree<Cell>(parameterList)); new CellOperationImpl(processor).Check(result, row.Branches.Last()); }
public void DoTableFlow(CellProcessor processor, FlowInterpreter interpreter, Tree<Cell> table) { this.interpreter = interpreter; this.processor = processor; if (processor.TestStatus.IsAbandoned) return; hasFinishedTable = false; for (var i = 0; i < table.Branches.Count; i++) { if (i < rowsToSkip) continue; if (hasFinishedTable) break; ProcessFlowRow(table, i); } }
public static TypedValue InvokeSpecialAction(this Tree<Cell> row, CellProcessor processor, FlowInterpreter interpreter) { var specialActionName = processor.ParseTree<Cell, MemberName>(row.Branches[0]); try { var result = processor.Operate<InvokeSpecialOperator>(new TypedValue(interpreter), specialActionName, row); if (result.IsValid) { SetSyntaxKeyword(row); } return result; } catch (System.Exception) { SetSyntaxKeyword(row); throw; } }
public static object ExecuteFlowRowMethod(this FlowInterpreter interpreter, CellProcessor processor, Tree<Cell> row) { try { var cells = row.Skip(1); return processor.ExecuteWithThrow(interpreter, interpreter.MethodRowSelector.SelectMethodCells(cells), interpreter.MethodRowSelector.SelectParameterCells(cells), row.ValueAt(1)). Value; } catch (ParseException<Cell> e) { processor.TestStatus.MarkException(e.Subject, e.InnerException); throw new IgnoredException(); } }
public void Evaluate(CellProcessor processor, FlowInterpreter interpreter) { var specialActionName = processor.ParseTree<Cell, MemberName>(row.Branches[0]); var result = processor.Operate<InvokeSpecialOperator>(new TypedValue(interpreter), specialActionName, row.Branches[0]); if (result.IsValid) { row.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword); return; } if (!result.IsValid) { processor.Execute(interpreter, interpreter.MethodRowSelector.SelectMethodCells(row), interpreter.MethodRowSelector.SelectParameterCells(row), row.ValueAt(0)); } }
public static void SetOption(CellProcessor processor, String name, String value) { String normalname = NameNormaliser.NormaliseName(name); if ("fixedlengthstringparsing".Equals(normalname)) { fixedLengthStringParsing = Boolean.Parse(value); if (fixedLengthStringParsing) processor.AddOperator(typeof(ParseQuotedString).FullName); else processor.RemoveOperator(typeof(ParseQuotedString).FullName); } else if ("bindsymbols".Equals(normalname)) { bindSymbols = Boolean.Parse(value); } else throw new ApplicationException("Unsupported option" + name); }
public void Interpret(CellProcessor processor, Tree<Cell> table) { processor.TestStatus.TableCount--; var facility = processorIdentifier.Matches(table.ValueAt(0, 1).Text) ? processor : processor.Memory.GetItem(table.ValueAt(0, 1).Text); if (table.Branches[0].Branches.Count > 2) { var currentRow = table.Branches[0].Skip(2); Execute(processor, facility, currentRow); } new Traverse<Cell>() .Rows.All(row => Execute(processor, facility, row)) .VisitTable(table); }
public BindingFactory(CellProcessor processor, MutableDomainAdapter adapter, TargetObjectProvider targetProvider) { this.processor = processor; this.adapter = adapter; this.targetProvider = targetProvider; }
public void Interpret(CellProcessor processor, Tree <Cell> table) { processor.TestStatus.TableCount--; processor.Get <Symbols>().Clear(); }
public void Prepare(CellProcessor processor, Tree <Cell> row) { Processor = processor; GetArgsForRow(row); }
static Type FindType(CellProcessor processor, string facilityName, string action) { return(processor.ApplicationUnderTest.FindType(new GracefulNameMatcher(ConfigurationNames.TypeName(facilityName, action))).Type); }
public void Interpret(CellProcessor processor, Tree <Cell> table) { new Traverse <Cell>() .All(row => row.Branches.Select(branch => branch.Value).Where(cell => cell.Text == "good").ForEach(cell => processor.TestStatus.MarkRight(cell))) .VisitTable(table); }
public void Execute(CellProcessor cellProcessor) { cellProcessor.Operate <RunTestOperator>(ParsedInput, writer); }
public SetMatchStrategy(CellProcessor processor, Parse theHeaderRow) : base(processor, theHeaderRow) { }
public static TypedValue Execute(this CellProcessor processor, object target, Tree <Cell> memberName, Tree <Cell> parameters) { return(processor.Execute(target, memberName, parameters, new CellBase(string.Empty))); }
static async Task Main(string[] args) { Console.ForegroundColor = ConsoleColor.Blue; IExpressionEvaluator _evaluator = new ExpressionEvaluator(); IFileService _fileService = new FileService(); IValidator _validator = new Validator(); ICellProcessor _cellService = new CellProcessor(); Interactions.GreetUser(); Interactions.AskForFilesCount(); string filesCount = Console.ReadLine(); int filesCountNum; while (!_validator.FilesCountIsValid(filesCount, out filesCountNum)) { Interactions.AskForFilesCount(); filesCount = Console.ReadLine(); } for (int i = 0; i < filesCountNum; i++) { string filePath, outParameter, formula; Interactions.AskForSrcFilePath(); filePath = Console.ReadLine(); while (!_validator.FilePathIsValid(filePath)) { Interactions.AskForSrcFilePath(); filePath = Console.ReadLine(); } var fileLines = await File.ReadAllLinesAsync(filePath); if (!_validator.FileLinesAreValid(fileLines)) { return; } Interactions.AskForOutParameter(); outParameter = Console.ReadLine(); while (!_validator.OutParameterIsValid(outParameter)) { Interactions.AskForOutParameter(); outParameter = Console.ReadLine(); } Interactions.AskForFormula(); formula = Console.ReadLine(); while (!_validator.FormulaIsValid(formula)) { Interactions.AskForFormula(); formula = Console.ReadLine(); } List <FileLine> lines = _fileService.MapFileLines(fileLines); try { await Task.Run(() => // cpu-bound operation, better to perform in a separate thread { Parallel.ForEach(lines, l => l.CalculatedValue = _evaluator.EvaluateExpression(formula.ToLower().Replace("x", l.Value.ToString()))); }); } catch (FormatException) { Console.WriteLine("Wrong formula"); return; } catch (Exception) { Console.WriteLine("Something went wrong while evaluating expression"); } if (outParameter.ToLower().Equals("-f")) { await _fileService.WriteLinesToFileAsync(filePath, lines); // I/O-bound operation, better to await without Task.Run() Interactions.AnnounceSuccess(); } else { foreach (var line in lines) { Console.WriteLine($"{line.LineNumber}: {line.Value}: {line.CalculatedValue}"); } } } Console.ReadKey(); }
public FlowKeywords(FlowInterpreter fixture, CellProcessor processor) { this.fixture = fixture; this.processor = processor; }
public InterpretFlow(CellProcessor processor, FlowInterpreter interpreter) { this.interpreter = interpreter; this.processor = processor; }
public CellMatcher(CellProcessor processor) { Processor = processor; }
public CellOperationImpl(CellProcessor processor) { this.processor = processor; }
public static void Check(this CellProcessor processor, TypedValue actualValue, Tree <Cell> expectedCell) { processor.Operate <CheckOperator>( CellOperationValue.Make(actualValue), expectedCell); }
public static T GetSystemUnderTest <T>(this CellProcessor processor) where T : class { return(processor.CallStack.GetSystemUnderTest <T>()); }
public static TypedValue ExecuteWithThrow(this CellProcessor processor, object target, Tree <Cell> memberName) { return(processor.ExecuteWithThrow(target, memberName, new CellTree(), new CellBase(string.Empty))); }
public static void Check(this CellProcessor processor, object systemUnderTest, Tree <Cell> memberName, Tree <Cell> expectedCell) { processor.Check(systemUnderTest, memberName, new CellTree(), expectedCell); }
public StoryTest(CellProcessor processor, StoryTestWriter writer) { this.processor = processor; this.writer = writer; }
public static V Get <V>(this CellProcessor processor) where V : new() { return(processor.Memory.GetItem <V>()); }
public DeepCopy(CellProcessor processor) { this.processor = processor; }
public static void Check(this CellProcessor processor, object systemUnderTest, Tree <Cell> memberName, Tree <Cell> parameters, Tree <Cell> expectedCell) { processor.Operate <CheckOperator>( CellOperationValue.Make(systemUnderTest, memberName, parameters), expectedCell); }
public TypedValue Decorate(CellProcessor processor, Tree <Cell> element, Func <TypedValue> action) { return(action()); }
public void DoSetUp(CellProcessor processor, Tree <Cell> table) { Prepare(processor, table.Branches[0]); ExecuteOptionalMethod(InvokeSetUpTearDown.SetUpMethod, (Parse)table.Branches[0].Branches[0]); }
public void Interpret(CellProcessor processor, Tree <Cell> table) { }
public ListMatcher(CellProcessor processor, ListMatchStrategy strategy) { this.strategy = strategy; this.processor = processor; }
public PatternMemberMatcher(CellProcessor processor, object instance, MemberSpecification specification) { this.processor = processor; this.specification = specification; this.instance = instance; }
public PatternRuntimeMember(CellProcessor processor, RuntimeMember baseMember, string[] patternParameters) { this.baseMember = baseMember; this.processor = processor; this.patternParameters = patternParameters; }
public QueryMatchStrategy(CellProcessor processor, Parse theHeaderRow, bool isOrdered) : base(processor, theHeaderRow) { this.isOrdered = isOrdered; }
public static TypedValue Execute(this CellProcessor processor, object systemUnderTest, Tree <Cell> memberName, Tree <Cell> parameters, Cell targetCell) { return(processor.Operate <ExecuteOperator>(systemUnderTest, memberName, parameters, targetCell)); }
public InputBinding(CellProcessor processor, TargetObjectProvider targetProvider, Tree<Cell> memberCell) { this.processor = processor; this.memberCell = memberCell; this.targetProvider = targetProvider; }
public IncludeAction(CellProcessor processor) { this.processor = processor; }