diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs index 617581bc63..eafeae7519 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs @@ -162,9 +162,9 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling #region Fill - private IEnumerator> groupEnumerator; - private IEnumerable> groupedList; - private IEnumerator listEnumerator; + IEnumerator> groupEnumerator; + IEnumerable> groupedList; + IEnumerator listEnumerator; public void Fill(List collection) { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs index fa8a3ab43c..e13cdbb5f1 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs @@ -95,6 +95,62 @@ namespace ICSharpCode.Reporting.Test.DataSource [Test] public void GroupbyOneColumnAndFill () { + var dataItemsCollection = CreateDataItems(); + var repiortsettings = new ReportSettings(); + repiortsettings.GroupColumnCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); + repiortsettings.GroupColumnCollection.Add( new GroupColumn("RandomInt",1,ListSortDirection.Ascending)); + + var collectionSource = new CollectionDataSource (list,repiortsettings); + collectionSource.Bind(); + int i = 0; + do { + collectionSource.Fill(dataItemsCollection); + Console.WriteLine("first : <{0}> Last <{1}> Group <{2}> Randomint <{3}>",((BaseDataItem)dataItemsCollection[0]).DBValue, + ((BaseDataItem)dataItemsCollection[1]).DBValue, + ((BaseDataItem)dataItemsCollection[2]).DBValue, + ((BaseDataItem)dataItemsCollection[3]).DBValue); + i ++; + }while (collectionSource.MoveNext()); + + Assert.That(i,Is.EqualTo(collectionSource.Count)); + } + + + [Test] + public void FillDataIncludedInRow() { + + var baseRow = new BaseRowItem(); + var dataItemsCollection = CreateDataItems(); + baseRow.Items.AddRange(dataItemsCollection); + + var row = new System.Collections.Generic.List(); + row.Add(baseRow); + var reportSettings = new ReportSettings(); + var collectionSource = new CollectionDataSource (list,reportSettings); + collectionSource.Bind(); + int i = 0; + do { + collectionSource.Fill(row); + var r = (BaseRowItem)row[0]; + foreach (var element in r.Items) { + Assert.That(((BaseDataItem)element).DBValue,Is.Not.Empty); + } + i ++; + }while (collectionSource.MoveNext()); + + Assert.That(i,Is.EqualTo(collectionSource.Count)); + } + + + [Test] + public void RowContainsRowAndItem() { + var row = new System.Collections.Generic.List(); + var gItem = new BaseDataItem(){ + ColumnName = "GroupItem" + }; + row.Add(gItem); + + var baseRow = new BaseRowItem(); var ric = new System.Collections.Generic.List(){ new BaseDataItem(){ @@ -103,35 +159,45 @@ namespace ICSharpCode.Reporting.Test.DataSource }, new BaseDataItem(){ ColumnName = "Firstname" - }, - - new BaseDataItem(){ - ColumnName = "GroupItem" - }, - - new BaseDataItem(){ - ColumnName = "RandomInt" } }; + baseRow.Items.AddRange(ric); + row.Add(baseRow); var rs = new ReportSettings(); - rs.GroupColumnCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); - rs.GroupColumnCollection.Add( new GroupColumn("RandomInt",1,ListSortDirection.Ascending)); - var collectionSource = new CollectionDataSource (list,rs); collectionSource.Bind(); int i = 0; do { - collectionSource.Fill(ric); - Console.WriteLine("first : <{0}> Last <{1}> Group <{2}> Randomint <{3}>",((BaseDataItem)ric[0]).DBValue, - ((BaseDataItem)ric[1]).DBValue, - ((BaseDataItem)ric[2]).DBValue, - ((BaseDataItem)ric[3]).DBValue); + collectionSource.Fill(row); + var res = (BaseDataItem)row.Find(c => ((BaseDataItem)c).ColumnName == "GroupItem"); + Assert.That(res.DBValue,Is.Not.Empty); i ++; }while (collectionSource.MoveNext()); Assert.That(i,Is.EqualTo(collectionSource.Count)); } - + + + System.Collections.Generic.List CreateDataItems() { + var ric = new System.Collections.Generic.List(){ + new BaseDataItem(){ + ColumnName = "Lastname" + + }, + new BaseDataItem(){ + ColumnName = "Firstname" + }, + + new BaseDataItem(){ + ColumnName = "GroupItem" + }, + new BaseDataItem(){ + ColumnName = "RandomInt" + } + }; + return ric; + } + [SetUp] public void CreateList() {