Browse Source

Fix UnitTest's for GroupingWizard

pull/14/head
peterforstmeier 15 years ago
parent
commit
4a52cac3c5
  1. 100
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Wizard/Generators/GenerateListWithGroupFixture.cs
  2. 46
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Test/Wizard/Generators/GenertaeTableWithgroupFixture.cs

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

@ -3,6 +3,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Linq;
using ICSharpCode.Reports.Addin.ReportWizard; using ICSharpCode.Reports.Addin.ReportWizard;
using ICSharpCode.Reports.Core; using ICSharpCode.Reports.Core;
using NUnit.Framework; using NUnit.Framework;
@ -21,68 +24,45 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators
[Test] [Test]
public void PageDetail_First_Item_Should_GroupedRow() public void PageDetail_Should_Contains_GroupedHeader()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseSection section = this.reportModel.DetailSection;
BaseReportItem item = s.Items[0];
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseGroupedRow)));
}
[Test] //GroupHeader
public void GroupHeader_Should_Contain_DataItem() var c = new Collection<ICSharpCode.Reports.Core.BaseGroupedRow>(section.Items.OfType<ICSharpCode.Reports.Core.BaseGroupedRow>().ToList());
{ Assert.That(c.Count,Is.GreaterThanOrEqualTo(1));
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection;
ICSharpCode.Reports.Core.BaseGroupedRow groupedRow = (ICSharpCode.Reports.Core.BaseGroupedRow)s.Items[0];
var item = groupedRow.Items[0];
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseDataItem)));
} }
[Test] [Test]
public void PageDetail_Second_Item_Should_Row() public void Section_Should_Contain_DataRow()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseSection section = this.reportModel.DetailSection;
BaseReportItem item = s.Items[1]; //DatatRow
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseRowItem))); var c = new Collection<ICSharpCode.Reports.Core.BaseRowItem>(section.Items.OfType<ICSharpCode.Reports.Core.BaseRowItem>().ToList());
Assert.That(c.Count,Is.GreaterThanOrEqualTo(1));
} }
[Test] [Test]
public void DataRow_Should_Contain_DataItem() public void DataRow_Should_Contain_GroupFooter()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseSection section = this.reportModel.DetailSection;
ICSharpCode.Reports.Core.BaseRowItem dataRow = (ICSharpCode.Reports.Core.BaseRowItem)s.Items[1];
var item = dataRow.Items[0];
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseDataItem)));
}
//GroupFooter
[Test] var c = new Collection<ICSharpCode.Reports.Core.GroupFooter>(section.Items.OfType<ICSharpCode.Reports.Core.GroupFooter>().ToList());
public void PageDetail_Should_Contain_Two_items() Assert.That(c.Count,Is.GreaterThanOrEqualTo(1));
{
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection;
Assert.That(s.Items.Count.Equals(2));
} }
[Test] [Test]
public void PageDetail_First_Item_Should_Contain_GroupedRow() public void PageDetail_Should_Contain_Three_Items()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseSection section = this.reportModel.DetailSection;
Assert.That(s.Items.Count.Equals(2)); Assert.That(section.Items.Count.Equals(3));
} }
[Test]
public void PageDetail_Row_Should_Contain_DataItems()
{
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection;
ICSharpCode.Reports.Core.BaseRowItem rowItem = (ICSharpCode.Reports.Core.BaseRowItem)s.Items[0];
Assert.IsTrue(rowItem.Items.Count > 0);
BaseReportItem item = rowItem.Items[0];
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseDataItem)));
}
#region Setup/Teardown #region Setup/Teardown
@ -99,45 +79,7 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators
{ {
// TODO: Add tear down code. // 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.ListLayout);
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) private static ReportStructure CreateReportStructure (string reportName)
{ {
ReportStructure structure = new ReportStructure(); ReportStructure structure = new ReportStructure();

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

@ -8,6 +8,8 @@
*/ */
using System; using System;
using System.Collections.ObjectModel;
using System.Linq;
using ICSharpCode.Reports.Addin.ReportWizard; using ICSharpCode.Reports.Addin.ReportWizard;
using ICSharpCode.Reports.Core; using ICSharpCode.Reports.Core;
using NUnit.Framework; using NUnit.Framework;
@ -23,40 +25,48 @@ namespace ICSharpCode.Reports.Addin.Test.Wizard.Generators
[Test] [Test]
public void PageDetail_First_Item_Should_Table() public void Table_Should_Contains_GroupedHeader()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseTableItem table = CreateContainer();
var item = s.Items[0]; //GroupHeader
Assert.That(item,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseTableItem))); var c = new Collection<ICSharpCode.Reports.Core.BaseGroupedRow>(table.Items.OfType<ICSharpCode.Reports.Core.BaseGroupedRow>().ToList());
Assert.That(c.Count,Is.GreaterThanOrEqualTo(1));
} }
[Test] [Test]
public void Table_Should_Contain_Three_Rows() public void Table_Should_Contain_DataRow()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseTableItem table = CreateContainer();
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem; //DataRow
Assert.That(table.Items.Count,Is.GreaterThanOrEqualTo(3)); var c = new Collection<ICSharpCode.Reports.Core.BaseRowItem>(table.Items.OfType<ICSharpCode.Reports.Core.BaseRowItem>().ToList());
Assert.That(c.Count,Is.GreaterThanOrEqualTo(1));
} }
[Test] [Test]
public void Table_FirstItem_Should_Row () public void Table_Should_Contain_GroupFooter()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseTableItem table = CreateContainer();
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem; //GroupFooter
var row = table.Items[0]; var c = new Collection<ICSharpCode.Reports.Core.GroupFooter>(table.Items.OfType<ICSharpCode.Reports.Core.GroupFooter>().ToList());
Assert.That(row,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseRowItem))); Assert.That(c.Count,Is.GreaterThanOrEqualTo(1));
} }
[Test] [Test]
public void Table_SecondItem_Should_GroupRow () public void PageDetail_Should_Contain_Four_Items()
{ {
ICSharpCode.Reports.Core.BaseSection s = this.reportModel.DetailSection; ICSharpCode.Reports.Core.BaseTableItem table = CreateContainer();
ICSharpCode.Reports.Core.BaseTableItem table = s.Items[0] as ICSharpCode.Reports.Core.BaseTableItem; Assert.That(table.Items.Count.Equals(4));
var row = table.Items[1]; }
Assert.That(row,Is.InstanceOf(typeof(ICSharpCode.Reports.Core.BaseGroupedRow)));
private ICSharpCode.Reports.Core.BaseTableItem CreateContainer ()
{
ICSharpCode.Reports.Core.BaseSection section = this.reportModel.DetailSection;
ICSharpCode.Reports.Core.BaseTableItem table = section.Items[0] as ICSharpCode.Reports.Core.BaseTableItem;
return table;
} }
#region setup / TearDown #region setup / TearDown

Loading…
Cancel
Save