Browse Source

UnitTest for CreateGroupedReport from TableLayout.cs

pull/2/head
peterforstmeier 15 years ago
parent
commit
c0cfc4b81b
  1. 4
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportWizard/ReportLayout/TableLayout.cs
  2. 1
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/ICSharpCode.Reports.Addin.Test.csproj
  3. 5
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Wizard/Generators/GenerateListWithGroupFixture.cs
  4. 127
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Wizard/Generators/GenertaeTableWithgroupFixture.cs

4
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportWizard/ReportLayout/TableLayout.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard @@ -46,7 +46,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
base.ParentItem = table;
ICSharpCode.Reports.Core.BaseRowItem headerRow = CreateRowWithTextColumns(ParentItem, this.reportItems);
ParentItem.Items.Add (headerRow);
Point insertLocation = new Point (margin.Left,headerRow.Location.Y + headerRow.Size.Height + margin.Bottom + margin.Top);
@ -78,8 +78,6 @@ namespace ICSharpCode.Reports.Addin.ReportWizard @@ -78,8 +78,6 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
insertLocation = new Point(margin.Left,insertLocation.Y + detailRow.Size.Height + margin.Bottom + margin.Top);
ParentItem.Items.Add (headerRow);
ParentItem.Items.Add (detailRow);
ParentItem.Size = CalculateContainerSize(ParentItem,margin);

1
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/ICSharpCode.Reports.Addin.Test.csproj

@ -70,6 +70,7 @@ @@ -70,6 +70,7 @@
<Compile Include="Wizard\Generators\GeneratePlainReportFixture_2.cs" />
<Compile Include="Wizard\Generators\GenerateTableReportFixture.cs" />
<Compile Include="Wizard\Generators\GeneratorFactoryFixture.cs" />
<Compile Include="Wizard\Generators\GenertaeTableWithgroupFixture.cs" />
<Compile Include="Wizard\Generators\ReportGenerationHelper.cs" />
<Compile Include="Wizard\ReportStructureFixture.cs" />
</ItemGroup>

5
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Wizard/Generators/GenerateListWithGroupFixture.cs

@ -99,7 +99,7 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators @@ -99,7 +99,7 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators
{
// TODO: Add tear down code.
}
/*
private static ReportModel CreateModel (string reportName)
{
@ -120,6 +120,7 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators @@ -120,6 +120,7 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators
customizer.Set("Generator", structure);
customizer.Set("ReportLayout",GlobalEnums.ReportLayout.ListLayout);
IReportGenerator generator = new GeneratePushDataReport(m,customizer);
generator.GenerateReport();
@ -136,7 +137,7 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators @@ -136,7 +137,7 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators
return model;
}
*/
private static ReportStructure CreateReportStructure (string reportName)
{
ReportStructure structure = new ReportStructure();

127
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Wizard/Generators/GenertaeTableWithgroupFixture.cs

@ -0,0 +1,127 @@ @@ -0,0 +1,127 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 03.10.2010
* Time: 17:26
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using ICSharpCode.Reports.Addin.ReportWizard;
using ICSharpCode.Reports.Core;
using NUnit.Framework;
namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators
{
[TestFixture]
public class GenertaeTableWithGroupFixture
{
private const string reportName = "TableBasedReport";
private ReportModel reportModel;
[Test]
public void PageDetail_First_Item_Should_Table()
{
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection;
var item = s.Items[0];
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseTableItem)));
}
[Test]
public void Table_Should_Contain_Three_Rows()
{
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection;
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem;
Assert.That(table.Items.Count,Is.GreaterThanOrEqualTo(3));
}
[Test]
public void Table_FirstItem_Should_Row ()
{
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection;
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem;
var row = table.Items[0];
Assert.That(row,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseRowItem)));
}
[Test]
public void Table_SecondItem_Should_GroupRow ()
{
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection;
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem;
var row = table.Items[1];
Assert.That(row,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseGroupedRow)));
}
#region setup / TearDown
[TestFixtureSetUp]
public void Init()
{
this.reportModel = CreateModel(reportName);
}
[TestFixtureTearDown]
public void Dispose()
{
// TODO: Add tear down code.
}
private static ReportModel CreateModel (string reportName)
{
ReportStructure structure = CreateReportStructure(reportName);
AvailableFieldsCollection abstractColumns = new AvailableFieldsCollection();
AbstractColumn a1 = new AbstractColumn("Field1",typeof(System.String));
structure.AvailableFieldsCollection.Add(a1);
ICSharpCode.Reports.Core.BaseDataItem bri = new ICSharpCode.Reports.Core.BaseDataItem();
bri.Name ="Field1";
structure.ReportItemCollection.Add(bri);
structure.Grouping = "group";
ReportModel m = structure.CreateAndFillReportModel();
ICSharpCode.Core.Properties customizer = new ICSharpCode.Core.Properties();
customizer.Set("Generator", structure);
customizer.Set("ReportLayout",GlobalEnums.ReportLayout.TableLayout);
IReportGenerator generator = new GeneratePushDataReport(m,customizer);
generator.GenerateReport();
ReportLoader rl = new ReportLoader();
object root = rl.Load(generator.XmlReport.DocumentElement);
ReportModel model = root as ReportModel;
if (model != null) {
model.ReportSettings.FileName = GlobalValues.PlainFileName;
FilePathConverter.AdjustReportName(model);
} else {
throw new InvalidReportModelException();
}
return model;
}
private static ReportStructure CreateReportStructure (string reportName)
{
ReportStructure structure = new ReportStructure();
structure.ReportName = reportName;
structure.DataModel = GlobalEnums.PushPullModel.PushData;
structure.ReportType = GlobalEnums.ReportType.DataReport;
return structure;
}
#endregion
}
}
Loading…
Cancel
Save