Esempio n. 1
0
 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);
         }
     }
 }
Esempio n. 2
0
 public void DoCheckOperation(Parse expectedValue, CellRange cells)
 {
     CellOperation.Check(GetTargetObject(),
                         new CellRange(MethodCells(cells)),
                         new CellRange(ParameterCells(cells)),
                         expectedValue);
 }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
 public void DoCheckOperation(Parse expectedValue, CellRange cells)
 {
     CellOperation.Check(GetTargetObject(),
                         MethodRowSelector.SelectMethodCells(cells),
                         MethodRowSelector.SelectParameterCells(cells),
                         expectedValue);
 }
Esempio n. 5
0
        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;
            }
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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;
                }
            }
        }
Esempio n. 8
0
        // Actions //////////////////////////////////

        public virtual void Start()
        {
            actor = CellOperation.Create(cells.More.Text.Trim()).Value;
            var fixture = actor as Fixture;

            if (fixture != null)
            {
                fixture.Processor = Processor;
            }
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
0
 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();
     }
 }
Esempio n. 11
0
        // 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);
            }
        }
Esempio n. 12
0
        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;
            }
        }
Esempio n. 13
0
        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);
            }
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
 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);
     }
 }
Esempio n. 16
0
        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");
            }
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        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;
            }
        }
Esempio n. 20
0
        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);
            }
        }
Esempio n. 21
0
 public CheckBinding(CellOperation operation, TargetObjectProvider targetProvider, Tree<Cell> memberCell)
 {
     this.operation = operation;
     this.memberCell = memberCell;
     this.targetProvider = targetProvider;
 }
Esempio n. 22
0
 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;
     }
 }
Esempio n. 23
0
 public virtual void Press()
 {
     CellOperation.Invoke(actor, cells.More, new CellTree(), cells.More);
 }
Esempio n. 24
0
 public virtual void Check()
 {
     CellOperation.Check(GetTarget(actor), cells.More, cells.More.More);
 }
Esempio n. 25
0
        public static void Create(this CellOperation operation, MutableDomainAdapter adapter, string className, Tree <Cell> parameterCell)
        {
            TypedValue instance = operation.Create(className, parameterCell);

            adapter.SetSystemUnderTest(instance.Value);
        }
Esempio n. 26
0
 public CheckBinding(CellOperation operation, object target, Tree<Cell> memberCell)
 {
     this.operation = operation;
     this.memberCell = memberCell;
     this.target = target;
 }
Esempio n. 27
0
 public CreateBinding(CellOperation operation, MutableDomainAdapter adapter, string memberName)
 {
     this.operation = operation;
     this.adapter = adapter;
     this.memberName = memberName;
 }
Esempio n. 28
0
 public static void Check(this CellOperation operation, object systemUnderTest, Tree <Cell> memberName, Tree <Cell> expectedCell)
 {
     operation.Check(systemUnderTest, memberName, new CellTree(), expectedCell);
 }
Esempio n. 29
0
 public static TypedValue TryInvoke(this CellOperation operation, object target, Tree <Cell> memberName, Tree <Cell> parameters)
 {
     return(operation.TryInvoke(target, memberName, parameters, null));
 }
Esempio n. 30
0
 public static TypedValue TryInvoke(this CellOperation operation, object target, Tree <Cell> memberName)
 {
     return(operation.TryInvoke(target, memberName, new CellTree()));
 }
Esempio n. 31
0
        bool IsMatch(Parse row, int col)
        {
            TypedValue actual = CellOperation.Invoke(this, headerCells.At(col));

            return(CellOperation.Compare(actual, GetCellForColumn(row, col)));
        }
Esempio n. 32
0
 public CheckBinding(CellOperation operation, TargetObjectProvider targetProvider, Tree<Cell> memberCell)
 {
     this.operation = operation;
     this.memberCell = memberCell;
     this.targetProvider = targetProvider;
 }
Esempio n. 33
0
 public static TypedValue Create(this CellOperation operation, string className)
 {
     return(operation.Create(className, new CellTree()));
 }