예제 #1
0
        private bool IsFulfilled(
            [NotNull] IRow row1, int tableIndex1,
            [NotNull] IRow row2, int tableIndex2,
            [NotNull] out string conditionMessage,
            bool returnEmptyConditionMessage,
            [CanBeNull] out IColumnNames errorColumnNames,
            [CanBeNull] IDictionary <string, object> overridingFieldValues = null)
        {
            Assert.ArgumentNotNull(row1, nameof(row1));
            Assert.ArgumentNotNull(row2, nameof(row2));

            if (Condition == null)
            {
                // no condition
                conditionMessage = string.Empty;
                errorColumnNames = null;
                return(_undefinedConditionIsFulfilled);
            }

            var view = GetTableView(row1, tableIndex1, row2, tableIndex2);

            if (view.MatchesConstraint(overridingFieldValues, row1, row2))
            {
                // the condition is fulfilled
                conditionMessage = string.Empty;
                errorColumnNames = null;
                return(true);
            }

            if (_isDirected)
            {
                // the condition is to be checked only for (row1,row2)
                conditionMessage = returnEmptyConditionMessage
                                                           ? string.Empty
                                                           : view.ToString(_conciseMessage, row1, row2);
                errorColumnNames = view;
                return(false);
            }

            // the condition is not directed -> maybe it succeeds for (row2,row1)
            var invertedView = GetTableView(row2, tableIndex2, row1, tableIndex1);

            if (invertedView.MatchesConstraint(SwapRowAliases(overridingFieldValues),
                                               row2, row1))
            {
                // the condition is fulfilled
                conditionMessage = string.Empty;
                errorColumnNames = null;
                return(true);
            }

            conditionMessage = returnEmptyConditionMessage
                                                   ? string.Empty
                                                   : invertedView.ToString(_conciseMessage, row2, row1);
            errorColumnNames = invertedView;
            return(false);
        }
예제 #2
0
        public bool IsFulfilled([NotNull] IRow row1, int tableIndex1,
                                [NotNull] IRow row2, int tableIndex2,
                                [NotNull] out string conditionMessage,
                                [CanBeNull] out IColumnNames errorColumnNames,
                                [CanBeNull] IDictionary <string, object> overridingFieldValues =
                                null)
        {
            if (Condition == null)
            {
                conditionMessage = string.Empty;
                errorColumnNames = null;
                return(_undefinedConditionIsFulfilled);
            }

            const bool returnEmptyConditionMessage = false;

            return(IsFulfilled(row1, tableIndex1,
                               row2, tableIndex2,
                               out conditionMessage,
                               returnEmptyConditionMessage,
                               out errorColumnNames,
                               overridingFieldValues));
        }