Example #1
0
 public bool IsEqual(IEnumerable<object> actualValues, Tree<Cell> expectedValueCell) {
     var actuals = new Actuals(actualValues);
     var expectedRowNumber = 0;
     foreach (var expectedRow in expectedValueCell.Branches[0].Branches.Skip(1)) {
         var matchRowNumber = actuals.FindMatch(ExactMatch, expectedRowNumber, expectedRow);
         if (matchRowNumber == Actuals.Unmatched || (matchRowNumber != expectedRowNumber && strategy.IsOrdered)) return false;
         expectedRowNumber++;
     }
     return (actuals.UnmatchedCount == 0);
 }
Example #2
0
 public bool IsEqual(object theActualValue, Parse theExpectedValueCell)
 {
     var actuals = new Actuals((IList)theActualValue, strategy);
     int expectedRow = 0;
     foreach (Parse currentRow in new CellRange(theExpectedValueCell.Parts.Parts.More).Cells) {
         int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
         if (match < 0 || (match != expectedRow && strategy.IsOrdered)) return false;
         expectedRow++;
     }
     return (actuals.UnmatchedCount == 0);
 }
Example #3
0
 bool FindMatches(IEnumerable<Tree<Cell>> expectedRows, Actuals actuals) {
     var expectedRow = 0;
     foreach (var currentRow in expectedRows) {
         try {
             actuals.FindMatch(BestMatch, expectedRow, currentRow);
             expectedRow++;
         }
         catch (System.Exception e) {
             processor.TestStatus.MarkException(currentRow.ValueAt(0), e);
             return false;
         }
     }
     return true;
 }
Example #4
0
        public bool IsEqual(IEnumerable <object> theActualValue, Parse theExpectedValueCell)
        {
            var actuals     = new Actuals(theActualValue, strategy);
            int expectedRow = 0;

            foreach (Parse currentRow in new CellRange(theExpectedValueCell.Parts.Parts.More).Cells)
            {
                int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
                if (match < 0 || (match != expectedRow && strategy.IsOrdered))
                {
                    return(false);
                }
                expectedRow++;
            }
            return(actuals.UnmatchedCount == 0);
        }
Example #5
0
        public bool IsEqual(IEnumerable <object> actualValues, Tree <Cell> expectedValueCell)
        {
            var actuals           = new Actuals(actualValues);
            var expectedRowNumber = 0;

            foreach (var expectedRow in expectedValueCell.Branches[0].Branches.Skip(1))
            {
                var matchRowNumber = actuals.FindMatch(ExactMatch, expectedRowNumber, expectedRow);
                if (matchRowNumber == Actuals.Unmatched || (matchRowNumber != expectedRowNumber && strategy.IsOrdered))
                {
                    return(false);
                }
                expectedRowNumber++;
            }
            return(actuals.UnmatchedCount == 0);
        }
Example #6
0
        bool FindMatches(IEnumerable <Tree <Cell> > expectedRows, Actuals actuals)
        {
            var expectedRow = 0;

            foreach (var currentRow in expectedRows)
            {
                try {
                    actuals.FindMatch(BestMatch, expectedRow, currentRow);
                    expectedRow++;
                }
                catch (System.Exception e) {
                    processor.TestStatus.MarkException(currentRow.ValueAt(0), e);
                    return(false);
                }
            }
            return(true);
        }
Example #7
0
        public bool MarkCell(IEnumerable<object> theActualValue, Parse theTableRows)
        {
            var actuals = new Actuals(theActualValue, strategy);
            if (theTableRows.More == null && actuals.UnmatchedCount == 0) {
                processor.TestStatus.MarkRight(theTableRows);
            }
            bool result = true;
            int expectedRow = 0;
            foreach (Parse currentRow in new CellRange(theTableRows.More).Cells) {
                try {
                    int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
                    if (match < 0) {
                        MarkAsIncorrect(currentRow, "missing");
                        result = false;
                    }
                    expectedRow++;
                }
                catch (Exception e) {
                    processor.TestStatus.MarkException(currentRow.Parts, e);
                    return false;
                }
            }
            if (actuals.UnmatchedCount > 0 && !strategy.SurplusAllowed) {
                actuals.ShowSurplus(processor, theTableRows.Last);
                result = false;
            }

            Parse markRow = theTableRows.More;
            for (int row = 0; row < expectedRow; row++) {
                if (strategy.IsOrdered && actuals.IsOutOfOrder(row)) {
                    MarkAsIncorrect(markRow, "out of order");
                    result = false;
                }
                else if (actuals.Match(row) != null) {
                    TypedValue[] actualValues = strategy.ActualValues(actuals.Match(row));
                    int i = 0;
                    foreach (Parse cell in new CellRange(markRow.Parts).Cells) {
                        if (actualValues[i].Type != typeof(void) || cell.Text.Length > 0) {
                             new CellOperationImpl(processor).Check(actualValues[i], cell);

                        }
                        i++;
                    }
                }
                markRow = markRow.More;
            }

            if (!strategy.FinalCheck(processor.TestStatus)) return false;
            return result;
        }
Example #8
0
        public bool MarkCell(IEnumerable <object> theActualValue, Parse theTableRows)
        {
            var actuals = new Actuals(theActualValue, strategy);

            if (theTableRows.More == null && actuals.UnmatchedCount == 0)
            {
                processor.TestStatus.MarkRight(theTableRows);
            }
            bool result      = true;
            int  expectedRow = 0;

            foreach (Parse currentRow in new CellRange(theTableRows.More).Cells)
            {
                try {
                    int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
                    if (match < 0)
                    {
                        MarkAsIncorrect(currentRow, "missing");
                        result = false;
                    }
                    expectedRow++;
                }
                catch (Exception e) {
                    processor.TestStatus.MarkException(currentRow.Parts, e);
                    return(false);
                }
            }
            if (actuals.UnmatchedCount > 0 && !strategy.SurplusAllowed)
            {
                actuals.ShowSurplus(processor, theTableRows.Last);
                result = false;
            }

            Parse markRow = theTableRows.More;

            for (int row = 0; row < expectedRow; row++)
            {
                if (strategy.IsOrdered && actuals.IsOutOfOrder(row))
                {
                    MarkAsIncorrect(markRow, "out of order");
                    result = false;
                }
                else if (actuals.Match(row) != null)
                {
                    TypedValue[] actualValues = strategy.ActualValues(actuals.Match(row));
                    int          i            = 0;
                    foreach (Parse cell in new CellRange(markRow.Parts).Cells)
                    {
                        if (actualValues[i].Type != typeof(void) || cell.Text.Length > 0)
                        {
                            new CellOperationImpl(processor).Check(actualValues[i], cell);
                        }
                        i++;
                    }
                }
                markRow = markRow.More;
            }

            if (!strategy.FinalCheck(processor.TestStatus))
            {
                return(false);
            }
            return(result);
        }