public void ListContentDatasourceConUnaExpresionParaObtenerElListadoDesdeElModelo() { // arrange var listContent = ListContentWith1StaticContent(); var writer = WriterFactory.MockWriter(); // act var datasource = DatasourceFactory.GetDatasourceSimpleObject(); listContent.DataSourceExpression = "model.Hijos"; listContent.Write(writer, datasource); // assert writer.WriteCount.Should().Be.EqualTo(datasource.Hijos.Count()); }
public void LaExpresionDeExpresionContentPuedeIncluirVariablesDeContextoComoFecha() { // arrange var datasource = DatasourceFactory.GetDatasourceSimpleObject(); var writer = WriterFactory.MockWriter(); // act var content = new ExpressionContent(); content.Expression = @"Context.Date.ToString(""dd/MM/yyyy"")"; content.Write(writer, datasource); // assert writer.LastWritedText.Should().Be.EqualTo(DateTime.Today.ToString("dd/MM/yyyy")); }
public void HayUnContenidoQueEsUnaExpresionEvaluadaSobreElModelo() { // arrange var datasource = DatasourceFactory.GetDatasourceSimpleObject(); var writer = WriterFactory.MockWriter(); // act var content = new ExpressionContent(); content.Expression = "model.Nombre"; content.Write(writer, datasource); // assert writer.LastWritedText.Should().Be.EqualTo(datasource.Nombre); }
public void UnReportDefinitionSePuedeRenderizarComoExcel() { // arrange var reportDefinition = ReportFactory.GetReport(); var datasource = DatasourceFactory.GetDatasourceSimpleObject(); var renderer = CreateReportRenderer(); // act renderer.Render(datasource, reportDefinition, this.streamToWrite); streamToWrite.Close(); // assert File.Exists(this.filename).Should().Be.True(); var excelFile = this.GetStreamToWrite(); Executing.This(() => new HSSFWorkbook(excelFile, true)).Should().NotThrow(); }
public void RenderizaEnExcelConExpresionesEstaticasCeldasDeterminadas() { // arrange var reportDefinition = ReportFactory.GetReport(); var datasource = DatasourceFactory.GetDatasourceSimpleObject(); var renderer = CreateReportRenderer(); // act renderer.Render(datasource, reportDefinition, streamToWrite); streamToWrite.Close(); // assert var sheet = GetSheet(this.filename); foreach (var content in reportDefinition.Contents.Contents.OfType <StaticContent>()) { sheet.GetRow(content.Y.Value).GetCell(content.X.Value).StringCellValue.Should().Be.EqualTo(content.Text); } }
public void EnExcelSiElContenidoNoTieneCoordenadasDebenIrEnColumnasContiguas() { // arrange var reportDefinition = ReportFactory.GetReportSinCoordenadas(); var datasource = DatasourceFactory.GetDatasourceSimpleObject(); var renderer = CreateReportRenderer(); // act renderer.Render(datasource, reportDefinition, streamToWrite); streamToWrite.Close(); // assert var sheet = GetSheet(this.filename); var row = sheet.GetRow(0); for (int i = 0; i < reportDefinition.Contents.Contents.Count(); i++) { row.Cells[i].ColumnIndex.Should("cell" + i).Be.EqualTo(i); } }