private static void AttachDiffs(ReportParameters <RowDifference> rep, SnapshotTableDifferences tableDiffs) { var allCols = tableDiffs.RowDifferences.Where(r => r.Differences != null).SelectMany(r => r.Differences.Differences.Select(d => d.Name)).Distinct(); var key = tableDiffs.RowDifferences.FirstOrDefault()?.Key; rep.RemoveBufferLimit(); rep.Title(tableDiffs.TableDefinition.TableName); rep.AddColumn(rd => rd.DifferenceType.ToString(), cc => cc.Heading("Difference")); if (key != null) { var keyIndex = 0; foreach (var keyField in key.GetFieldNames()) { rep.AddColumn(rd => rd.Key.AllKeys.Skip(keyIndex).First(), cc => cc.Heading(keyField)); } } foreach (var col in allCols) { rep.AddColumn(rep.Lambda(rd => rd.Differences?.Differences.FirstOrDefault(fd => fd.Name == col)?.Before), cc => cc.Heading($"{col} before")); rep.AddColumn(rep.Lambda(rd => rd.Differences?.Differences.FirstOrDefault(fd => fd.Name == col)?.After), cc => cc.Heading($"{col} after")); } }
public void AddedColumnsHaveCorrectType() { //Arrange var parameters = new ReportParameters<TestRec>(); //Act parameters.AddColumn(i => i.Integer, c => { }); parameters.AddColumn(i => i.Double, c => { }); parameters.AddColumn(i => i.String, c => { }); //Assert var result = parameters.ColumnSource.Columns.Select(c => c.Type.Name).JoinWith(" "); Assert.That(result, Is.EqualTo("Int32 Double String")); }
private static void ReportDifferences(ReportParameters <RowDifference> rep, SnapshotTableDifferences tableDifferences, Output output, ChangeReportOptions changeReportOptions) { var differenceCols = tableDifferences.RowDifferences .Where(r => r.Differences?.Differences != null) .SelectMany(r => r.Differences.Differences.Select(d => d.Name)).Distinct(); var allCols = tableDifferences.TableDefinition.Columns.Where(c => differenceCols.Contains(c.Name)).Select(c => c.Name); rep.Title(tableDifferences.TableDefinition.TableName); rep.RemoveBufferLimit(); rep.AddColumn(rd => rd.DifferenceType.ToString(), cc => cc.Heading("Difference")); foreach (var col in allCols) { rep.AddColumn(rep.Lambda(rd => DifferenceDisplay(rd, col)), cc => cc.Heading(col)); } }
private void FormatRows(ReportParameters <SnapshotRow> tableParams) { tableParams .RemoveBufferLimit() .Title(TableDefinition.TableName); foreach (var column in TableDefinition.Columns) { tableParams.AddColumn(r => r.GetField(column.Name), cc => SnapshotColumnFormatter.Format(cc, TableDefinition, column)); } }
public void AddedColumnsAreRecorded() { //Arrange var parameters = new ReportParameters<TestRec>(); //Act parameters.AddColumn(i => i.Integer, c => { }); //Assert Assert.That(parameters.ColumnSource.Columns.Count(), Is.EqualTo(1)); }