Exemple #1
0
        private static RowDifference RequireColumns(RowDifference diff, List <string> requiredColumns)
        {
            var missingCols = requiredColumns
                              .Where(col => !diff.Differences?.Differences.Any(d => d.Name == col) ?? true)
                              .ToList();

            if (!missingCols.Any())
            {
                return(diff);
            }

            var differences = diff.Differences?.Differences?.ToList() ?? new List <FieldDifference>();

            FieldDifference MakeAddedColumnDifference(string col)
            {
                var value = (diff.Before ?? diff.After)?.GetField(col);

                return(new FieldDifference(col, value, value));
            }

            differences.AddRange(missingCols.Select(MakeAddedColumnDifference));
            var diffResult = new RowDataCompareResult(diff.Differences?.Matched ?? true, differences, diff.Before, diff.After);

            return(new RowDifference(diff.Key, diffResult, diff.DifferenceType));
        }
Exemple #2
0
        private static string DifferenceDisplay(RowDifference rd, string col)
        {
            var before = rd.Differences?.Differences.FirstOrDefault(fd => fd.Name == col)?.Before;
            var after  = rd.Differences?.Differences.FirstOrDefault(fd => fd.Name == col)?.After;

            if (before == null && after == null)
            {
                return(string.Empty);
            }

            var beforeString = before?.ToString();
            var afterString  = after?.ToString();

            if (before == null || after == null || before.Equals(after))
            {
                return(beforeString ?? afterString);
            }
            return($"{beforeString} ==> {afterString}");
        }
Exemple #3
0
 private static bool ContainsReference(RowDifference rowDifferences, string referencedField)
 {
     return(rowDifferences.Differences.Differences.Any(rd => rd.Name == referencedField));
 }
Exemple #4
0
 private static bool IsMatchByKeyValue(RowDifference row, (TableDefinition ReferencedTableDefinition, string ColumnName, object KeyValue) k)
Exemple #5
0
        private static object GetDateValue(string column, List <FieldDifference> dateDiffs, RowDifference rowDifference, bool before)
        {
            var colDiff = dateDiffs.FirstOrDefault(dd => dd.Name == column);
            var row     = before ? rowDifference.Before : rowDifference.After;
            var value   = before ? colDiff?.Before : colDiff?.After;

            if (row != null && !(value is DateTime))
            {
                var baseValue = row?.GetField(column);
                return(baseValue is DateTime dateTime ? $"{value} ({baseValue})" : value);
            }

            return(row == null ? null : value);
        }
Exemple #6
0
        private static object GetKeyValue(string keyCol, RowDifference rowDifference)
        {
            var diff = rowDifference.Differences.Differences.FirstOrDefault(d => d.Name == keyCol);

            return(diff?.After ?? diff?.Before);
        }
        private static RowDifference SubstituteRowDiffs(TableDefinition table, RowDifference row, List <SubstituteValues> substituteValues)
        {
            var compareResult = new RowDataCompareResult(row.Differences.Matched, SubstitutedDifferences(table, row.Differences, substituteValues), row.Before, row.After);

            return(new RowDifference(row.Key, compareResult, row.DifferenceType));
        }