Browse Source

RowItem and recursive conversion with UnitTest's

reports
Peter Forstmeier 12 years ago
parent
commit
9a34be4eba
  1. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
  2. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs
  3. 16
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs
  4. 7
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs
  5. 3
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj
  6. 17
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionConverterFixture.cs
  7. 70
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionWithContainerFixture.cs
  8. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs
  9. 39
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/ReportWithTwoItems.srd

1
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj

@ -145,6 +145,7 @@ @@ -145,6 +145,7 @@
<Compile Include="Src\Interfaces\IReportContainer.cs" />
<Compile Include="Src\Interfaces\IReportCreator.cs" />
<Compile Include="Src\Items\BaseDataItem.cs" />
<Compile Include="Src\Items\BaseRowItem.cs" />
<Compile Include="Src\Items\BaseSection.cs" />
<Compile Include="Src\Globals\GlobalEnums.cs" />
<Compile Include="Src\Globals\GlobalValues.cs" />

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors @@ -39,7 +39,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
public virtual void Visit (ExportContainer exportContainer) {
foreach (var element in exportContainer.ExportedItems) {
Console.WriteLine(((ExportText)element).ContentAlignment.ToString());
var ac = element as IAcceptor;
ac.Accept(this);
}

16
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.Reporting.Items
{
/// <summary>
/// Description of BaseRowItem.
/// </summary>
public class BaseRowItem:ReportContainer
{
public BaseRowItem()
{
}
}
}

7
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs

@ -44,6 +44,13 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter @@ -44,6 +44,13 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter
var itemsList = new List<IExportColumn>();
foreach (var element in items) {
var exportColumn = ExportColumnFactory.CreateItem(element);
var ec = element as IReportContainer;
if (ec != null) {
Console.WriteLine("yyyyyyyyyyy");
var l = CreateConvertedList(ec.Items);
((IExportContainer)exportColumn).ExportedItems.AddRange(l);
}
itemsList.Add(exportColumn);
}
return itemsList;

3
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj

@ -79,10 +79,11 @@ @@ -79,10 +79,11 @@
<Compile Include="src\Model\Report_FromListFixture.cs" />
<Compile Include="src\Model\Report_TwoItemsFixture.cs" />
<Compile Include="src\PageBuilder\BaseConvertFixture.cs" />
<Compile Include="src\PageBuilder\ContainerConverterFixture.cs" />
<Compile Include="src\PageBuilder\SectionConverterFixture.cs" />
<Compile Include="src\PageBuilder\FormBuilderFixture.cs" />
<Compile Include="src\PageBuilder\PageFixture.cs" />
<Compile Include="src\PageBuilder\PageLayoutFixture.cs" />
<Compile Include="src\PageBuilder\SectionWithContainerFixture.cs" />
<Compile Include="src\Properties\AssemblyInfo.cs" />
<Compile Include="src\Reportingfactory\FormPageFixture.cs" />
<Compile Include="src\Reportingfactory\GeneralReportLoading.cs" />

17
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerConverterFixture.cs → src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionConverterFixture.cs

@ -17,18 +17,18 @@ using NUnit.Framework; @@ -17,18 +17,18 @@ using NUnit.Framework;
namespace ICSharpCode.Reporting.Test.PageBuilder
{
[TestFixture]
public class ContainerConverterFixture
public class SectionConverterFixture
{
private IReportContainer container;
private Graphics graphics;
IReportContainer container;
Graphics graphics;
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ConverterThrowIfGraphicsEqualNull() {
var converter = new ContainerConverter(null,new Point(30,30));
}
[Test]
public void ConverterReturnExportContainer() {
var converter = new ContainerConverter(graphics,new Point(30,30));
@ -38,7 +38,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder @@ -38,7 +38,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder
[Test]
public void ConverterReturnExportContainerwithTwoItems()
public void ConverterReturnExportContainerWithTwoItems()
{
var converter = new ContainerConverter(graphics,new Point(30,30));
var result = converter.ConvertToExportContainer(container);
@ -56,6 +56,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder @@ -56,6 +56,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder
Assert.That(result.Location,Is.EqualTo(location));
}
[Test]
public void ParentInChildsIsSet () {
var converter = new ContainerConverter(graphics,container.Location);
@ -67,9 +68,9 @@ namespace ICSharpCode.Reporting.Test.PageBuilder @@ -67,9 +68,9 @@ namespace ICSharpCode.Reporting.Test.PageBuilder
Assert.That(element.Parent,Is.Not.Null);
}
}
[TestFixtureSetUp]
[SetUp]
public void Init()
{
container = new BaseSection(){

70
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionWithContainerFixture.cs

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
using ICSharpCode.Reporting.Interfaces;
using ICSharpCode.Reporting.Items;
using ICSharpCode.Reporting.PageBuilder.Converter;
using ICSharpCode.Reporting.PageBuilder.ExportColumns;
using NUnit.Framework;
namespace ICSharpCode.Reporting.Test.PageBuilder
{
[TestFixture]
public class SectionWithContainerFixture
{
IReportContainer section;
Graphics graphics;
[Test]
public void SectionContainsRowWithName() {
Assert.That(section.Items[0],Is.AssignableTo(typeof(BaseRowItem)));
Assert.That(section.Items[0].Name,Is.EqualTo("Row1"));
}
[Test]
public void SectionContainsOneItemThatIsRow() {
var converter = new ContainerConverter(graphics,section.Location);
var list = converter.CreateConvertedList(section.Items);
Assert.That(list.Count,Is.EqualTo(1));
}
[Test]
public void RowContainsOneItem() {
var converter = new ContainerConverter(graphics,section.Location);
var list = converter.CreateConvertedList(section.Items);
var item = list[0] as ExportContainer;
var text = item.ExportedItems[0];
Assert.That(text,Is.AssignableTo(typeof(ExportText)));
}
[SetUp]
public void Init()
{
section = new BaseSection(){
Size = new Size (720,60),
Location = new Point(50,50),
Name ="Section"
};
var row = new BaseRowItem(){
Name = "Row1"
};
row.Items.Add(new BaseTextItem(){
Name = "Item1",
Location = new Point(10,10),
Size = new Size (60,20)
});
section.Items.Add(row);
Bitmap bitmap = new Bitmap(700,1000);
graphics = Graphics.FromImage(bitmap);
}
}
}

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.Reporting.Test.Reportingfactory @@ -57,7 +57,7 @@ namespace ICSharpCode.Reporting.Test.Reportingfactory
var reportingFactory = new ReportingFactory();
var rc = reportingFactory.ReportCreator(stream,list);
Assert.That(rc,Is.Not.Null);
Assert.That(rc,Is.TypeOf(typeof(DataPageBuilder)));
Assert.That(rc,Is.TypeOf(typeof(DataPageBuilder)));
}

39
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/ReportWithTwoItems.srd

@ -66,22 +66,35 @@ @@ -66,22 +66,35 @@
<DrawBorder>False</DrawBorder>
<PageBreakAfter>False</PageBreakAfter>
<Items>
<BaseTextItem>
<Location>26, 22</Location>
<Size>100, 20</Size>
<BaseRowItem>
<Location>149, 22</Location>
<Size>310, 30</Size>
<BackColor>White</BackColor>
<Font>Microsoft Sans Serif, 10pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>True</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>TestText for Item in PageHeader</Text>
<DrawBorder>False</DrawBorder>
<ForeColor>ControlText</ForeColor>
<FrameColor>Black</FrameColor>
<ForeColor>Black</ForeColor>
<Name>BaseTextItem2147483646</Name>
</BaseTextItem>
<Items>
<BaseTextItem>
<Location>13, 7</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<Font>Microsoft Sans Serif, 10pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>True</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>TestText for Item in PageHeader</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>Black</ForeColor>
<Name>BaseTextItem2147483646</Name>
</BaseTextItem>
</Items>
<AlternateBackColor />
<ChangeBackColorEveryNRow>0</ChangeBackColorEveryNRow>
<Name>BaseRowItem1</Name>
</BaseRowItem>
</Items>
<FrameColor>Black</FrameColor>
<Name>ReportPageHeader</Name>

Loading…
Cancel
Save