Exemplo n.º 1
0
        public BindingOperation Make(Tree <Cell> nameCell)
        {
            string name = nameCell.Value.Text.Trim();

            if (NoOperationIsImpliedBy(name))
            {
                return(new NoBinding());
            }

            var cellOperation = new CellOperationImpl(processor);

            if (CheckIsImpliedBy(name))
            {
                return(new CheckBinding(cellOperation, targetProvider, nameCell));
            }

            string memberName = processor.ParseTree <Cell, MemberName>(nameCell).ToString();

            RuntimeMember member = RuntimeType.FindInstance(targetProvider, new IdentifierName(memberName), 1);

            if (member == null && newIdentifier.IsStartOf(name))
            {
                string newMemberName = name.Substring(4);
                return(new CreateBinding(processor, adapter, newMemberName));
            }

            return(new InputBinding(processor, targetProvider, nameCell));
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
        void ProcessFlowRow(Tree<Cell> table, int rowNumber)
        {
            var currentRow = table.Branches[rowNumber];
            try
            {
                var specialActionName = InvokeSpecialAction.MakeName(
                    processor.ParseTree<Cell, MemberName>(currentRow.Branches[0]).ToString());
                var result = processor.Invoke(interpreter, specialActionName, currentRow.Branches[0]);
                if (!result.IsValid) {
                     result = new CellOperationImpl(processor).TryInvoke(interpreter,
                         interpreter.MethodRowSelector.SelectMethodCells(currentRow),
                         interpreter.MethodRowSelector.SelectParameterCells(currentRow),
                         currentRow.Branches[0].Value);

                }
                if (!result.IsValid) {
                    if (result.IsException<MemberMissingException>() && currentRow.Branches[0].Value.Text.Length > 0) {
                        var newFixture = processor.ParseTree<Cell, Interpreter>(currentRow);
                        var adapter = newFixture as MutableDomainAdapter;
                        if (adapter != null) adapter.SetSystemUnderTest(interpreter.SystemUnderTest);
                        ProcessRestOfTable(newFixture, processor.MakeCell(string.Empty, table.Branches.Skip(rowNumber)));
                    }
                    else {
                        result.ThrowExceptionIfNotValid();
                    }
                }
                else {

                    if (processor.TestStatus.IsAbandoned) {
                        processor.TestStatus.MarkIgnore(currentRow.Value);
                        return;
                    }
                    if (result.Type == typeof(bool)) {
                        ColorMethodName(interpreter.MethodRowSelector.SelectMethodCells(currentRow), result.GetValue<bool>());
                    }
                    else {
                        new CellOperationImpl(processor)
                            .Wrap(result)
                            .As<Interpreter>(i => ProcessRestOfTable(i, processor.MakeCell(string.Empty, table.Branches.Skip(rowNumber))));
                    }
                }
            }
            catch (IgnoredException) {}
            catch (ParseException<Cell> e) {
                processor.TestStatus.MarkException(e.Subject, e);
                hasFinishedTable = true;
            }
            catch (System.Exception e) {
                processor.TestStatus.MarkException(currentRow.Branches[0].Value, e);
                hasFinishedTable = true;
            }
        }
Exemplo n.º 4
0
        public BindingOperation Make(Tree<Cell> nameCell)
        {
            string name = nameCell.Value.Text.Trim();

            if (NoOperationIsImpliedBy(name))
                return new NoBinding();

            var cellOperation = new CellOperationImpl(processor);

            if (CheckIsImpliedBy(name))
                return new CheckBinding(cellOperation, targetProvider, nameCell);

            string memberName =  processor.ParseTree<Cell, MemberName>(nameCell).ToString();

            RuntimeMember member = RuntimeType.FindInstance(targetProvider, new IdentifierName(memberName), 1);

            if (member == null && newIdentifier.IsStartOf(name)) {
                string newMemberName = name.Substring(4);
                return new CreateBinding(processor, adapter, newMemberName);
            }

            return new InputBinding(processor, targetProvider, nameCell);
        }
Exemplo n.º 5
0
        void ProcessFlowRow(Tree <Cell> table, int rowNumber)
        {
            var currentRow = table.Branches[rowNumber];

            try
            {
                var specialActionName = InvokeSpecialAction.MakeName(
                    processor.ParseTree <Cell, MemberName>(currentRow.Branches[0]).ToString());
                var result = processor.Invoke(interpreter, specialActionName, currentRow.Branches[0]);
                if (!result.IsValid)
                {
                    result = new CellOperationImpl(processor).TryInvoke(interpreter,
                                                                        interpreter.MethodRowSelector.SelectMethodCells(currentRow),
                                                                        interpreter.MethodRowSelector.SelectParameterCells(currentRow),
                                                                        currentRow.Branches[0].Value);
                }
                if (!result.IsValid)
                {
                    if (result.IsException <MemberMissingException>() && currentRow.Branches[0].Value.Text.Length > 0)
                    {
                        var newFixture = processor.ParseTree <Cell, Interpreter>(currentRow);
                        var adapter    = newFixture as MutableDomainAdapter;
                        if (adapter != null)
                        {
                            adapter.SetSystemUnderTest(interpreter.SystemUnderTest);
                        }
                        ProcessRestOfTable(newFixture, processor.MakeCell(string.Empty, table.Branches.Skip(rowNumber)));
                    }
                    else
                    {
                        result.ThrowExceptionIfNotValid();
                    }
                }
                else
                {
                    if (processor.TestStatus.IsAbandoned)
                    {
                        processor.TestStatus.MarkIgnore(currentRow.Value);
                        return;
                    }
                    if (result.Type == typeof(bool))
                    {
                        ColorMethodName(interpreter.MethodRowSelector.SelectMethodCells(currentRow), result.GetValue <bool>());
                    }
                    else
                    {
                        processor.Operate <WrapOperator>(result)
                        .As <Interpreter>(i => ProcessRestOfTable(i, processor.MakeCell(string.Empty, table.Branches.Skip(rowNumber))));
                    }
                }
            }
            catch (IgnoredException) {}
            catch (ParseException <Cell> e) {
                processor.TestStatus.MarkException(e.Subject, e);
                hasFinishedTable = true;
            }
            catch (System.Exception e) {
                processor.TestStatus.MarkException(currentRow.Branches[0].Value, e);
                hasFinishedTable = true;
            }
        }