Exemple #1
0
        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());
        }
Exemple #2
0
        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"));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        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);
            }
        }
Exemple #6
0
        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);
            }
        }