public void AddColumnReturnsBuilder() { var column = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); Assert.AreEqual(this.Sut, this.Sut.AddColumn(column)); }
public void ReplaceColumnOldNullThrows() { var column = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); Assert.ThrowsException <ArgumentNullException>( () => this.Sut.ReplaceColumn(null, column)); }
public void AddColumnAdds() { var column = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); this.Sut.AddColumn(column); Assert.IsTrue(this.Sut.Columns.Contains(column)); }
public void ReplaceColumnWithSelfNoOps() { var column = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); this.Sut.AddColumn(column); this.Sut.ReplaceColumn(column, column); Assert.AreEqual(1, this.Sut.Columns.Count); Assert.AreEqual(column, this.Sut.Columns.Single()); }
public void ReplaceColumnReturnsBuilder() { var columnOld = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); var columnNew = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); this.Sut.AddColumn(columnOld); var builder = this.Sut.ReplaceColumn(columnOld, columnNew); Assert.AreEqual(this.Sut, builder); }
public void ReplaceColumnThatDoesNotExistAdds() { var columnNotThere = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); var columnNew = new BaseDataColumn <string>( new ColumnMetadata(Guid.NewGuid(), "name"), new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); this.Sut.ReplaceColumn(columnNotThere, columnNew); Assert.AreEqual(1, this.Sut.Columns.Count); Assert.AreEqual(columnNew, this.Sut.Columns.Single()); }
public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData) { int maximumFieldCount = tableData.QueryOutput <int>( DataOutputPath.Create("Perf/GenericEvents/MaximumEventFieldCount")); var events = tableData.QueryOutput <ProcessedEventData <PerfGenericEvent> >( DataOutputPath.Create("Perf/GenericEvents/Events")); var tableGenerator = tableBuilder.SetRowCount((int)events.Count); var genericEventProjection = new GenericEventProjection(events); var eventNameColumn = new BaseDataColumn <string>( eventNameColumnConfig, genericEventProjection.Compose((genericEvent) => genericEvent.EventName)); tableGenerator.AddColumn(eventNameColumn); var eventIdColumn = new BaseDataColumn <uint>( eventIdColumnConfig, genericEventProjection.Compose((genericEvent) => genericEvent.Id)); tableGenerator.AddColumn(eventIdColumn); var cpuIdColumn = new BaseDataColumn <uint>( cpuIdColumnConfig, genericEventProjection.Compose((genericEvent) => genericEvent.CpuId)); tableGenerator.AddColumn(cpuIdColumn); var eventTimestampColumn = new BaseDataColumn <Timestamp>( eventTimestampColumnConfig, genericEventProjection.Compose((genericEvent) => genericEvent.Timestamp)); tableGenerator.AddColumn(eventTimestampColumn); tableGenerator.AddColumn(countColumnConfig, Projection.Constant(1)); // Add the field columns, with column names depending on the given event for (int columnIndex = 0; columnIndex < maximumFieldCount; columnIndex++) { string fieldName = "Field " + (columnIndex + 1); var genericEventFieldProjection = new GenericEventFieldProjection(columnIndex, genericEventProjection); var genericEventFieldNameProjection = genericEventFieldProjection.Compose((field) => field.HasValue ? field.Value.Name : string.Empty); // generate a column configuration var fieldColumnConfiguration = new ColumnConfiguration( new ColumnMetadata(GenerateGuidFromName(fieldName), fieldName, genericEventFieldNameProjection, fieldName), new UIHints { IsVisible = true, Width = 80, TextAlignment = TextAlignment.Left, }); var genericEventFieldAsStringProjection = genericEventFieldProjection.Compose((field) => field.HasValue ? field.Value.Value : string.Empty); tableGenerator.AddColumn(fieldColumnConfiguration, genericEventFieldAsStringProjection); } }