Browse Source

Remove unused classes, fix UnitTest's

reports
Peter Forstmeier 12 years ago
parent
commit
3be0a33931
  1. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
  2. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs
  3. 499
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs
  4. 6
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs
  5. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj
  6. 226
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs
  7. 22
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs

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

@ -87,7 +87,6 @@ @@ -87,7 +87,6 @@
<Compile Include="Src\BaseClasses\SortColumn.cs" />
<Compile Include="Src\Collections.cs" />
<Compile Include="Src\Configuration\AssemblyInfo.cs" />
<Compile Include="Src\DataManager\Listhandling\CollectionSource.cs" />
<Compile Include="Src\DataManager\Listhandling\CollectionDataSource.cs" />
<Compile Include="Src\DataManager\Listhandling\IndexList.cs" />
<Compile Include="Src\DataSource\Comparer\BaseComparer.cs" />

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs

@ -115,8 +115,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -115,8 +115,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
var sortProperty = listProperties.Find(reportSettings.SortColumnsCollection[0].ColumnName,true);
if(reportSettings.SortColumnsCollection.Count == 1) {
sortedList = baseList.OrderBy(o => o.GetType().GetProperty(sortProperty.Name).GetValue(o, null) );
}
return sortedList;
}

499
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs

@ -1,499 +0,0 @@ @@ -1,499 +0,0 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 21.05.2013
* Time: 20:09
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.DataSource;
using ICSharpCode.Reporting.DataSource.Comparer;
using ICSharpCode.Reporting.Interfaces;
using ICSharpCode.Reporting.Interfaces.Data;
using ICSharpCode.Reporting.Items;
namespace ICSharpCode.Reporting.DataManager.Listhandling
{
/// <summary>
/// Description of CollectionHandling.
/// </summary>
public class CollectionSource:IDataViewHandling
{
readonly PropertyDescriptorCollection listProperties;
readonly DataCollection<object> baseList;
readonly ReportSettings reportSettings;
readonly Type elementType;
public CollectionSource(IEnumerable list, Type elementType, ReportSettings reportSettings)
{
this.elementType = elementType;
baseList = CreateBaseList(list, elementType);
// elementType = baseList[0].GetType();
this.reportSettings = reportSettings;
this.listProperties = this.baseList.GetItemProperties(null);
IndexList = new IndexList();
}
#region IDataViewHandling
public int Count
{
get {
return this.baseList.Count;
}
}
public Collection<AbstractColumn> AvailableFields {
get {
var availableFields = new Collection<AbstractColumn>();
foreach (PropertyDescriptor p in this.listProperties){
availableFields.Add (new AbstractColumn(p.Name,p.PropertyType));
}
return availableFields;
}
}
protected object Current_test {get;private set;}
public object Current {
get {
return baseList[((BaseComparer)IndexList[CurrentPosition]).ListIndex];
}
}
public int CurrentPosition {
get {
return IndexList.CurrentPosition;
}
set {
if ((value > -1)|| (value > this.IndexList.Count)){
this.IndexList.CurrentPosition = value;
}
// BaseComparer bc = GetComparer(value);
// Current = baseList[bc.ListIndex];
// current = this.baseList[((BaseComparer)IndexList[value]).ListIndex];
}
}
public bool MoveNext()
{
this.IndexList.CurrentPosition ++;
return this.IndexList.CurrentPosition<this.IndexList.Count;
}
public void Bind()
{
if (reportSettings.GroupColumnCollection.Any()) {
this.Group();
} else {
this.Sort ();
}
}
public IndexList IndexList {get; private set;}
#endregion
#region Fill
public void Fill(List<IPrintableObject> collection)
{
foreach (IPrintableObject item in collection)
{
if (item is IDataItem) {
FillInternal(item as IDataItem);
}
}
}
void FillInternal (IDataItem item) {
item.DBValue = String.Empty;
var p = listProperties.Find(item.ColumnName,true);
item.DBValue = p.GetValue(Current).ToString();
if (String.IsNullOrEmpty(item.DataType)) {
item.DataType = p.PropertyType.ToString();
}
}
#endregion
#region Fill_Test
private IEnumerable<IGrouping<object, BaseComparer>> newList;
private IEnumerator<IGrouping<object, BaseComparer>> groupEnumerator;
private IEnumerator<BaseComparer> listEnumerator;
public void Fill_Test (List<IPrintableObject> collection) {
var currentKey = groupEnumerator.Current;
Console.WriteLine("{0}",currentKey.Key);
var z = listEnumerator.Current;
Console.WriteLine("\t...{0} - {1}",((BaseComparer)z).ListIndex.ToString(),
((BaseComparer)z).ObjectArray[0].ToString());
foreach (IPrintableObject item in collection)
{
var dbItem = item as IDataItem;
if (dbItem != null) {
dbItem.DBValue = String.Empty;
var p = listProperties.Find(dbItem.ColumnName,true);
dbItem.DBValue = p.GetValue(Current_test).ToString();
if (String.IsNullOrEmpty(dbItem.DataType)) {
dbItem.DataType = p.PropertyType.ToString();
}
}
}
}
public bool MoveNext_Test_List() {
var canMove = listEnumerator.MoveNext();
if (! canMove) {
var groupCanMove = groupEnumerator.MoveNext();
if (groupCanMove) {
listEnumerator = groupEnumerator.Current.GetEnumerator();
canMove = listEnumerator.MoveNext();
// Current_test = listEnumerator.Current;
Current_test = baseList[listEnumerator.Current.ListIndex];
} else {
Console.WriteLine("end");
}
} else {
Current_test = baseList[listEnumerator.Current.ListIndex];
}
return canMove;
}
#endregion
#region Grouping
public void Group()
{
var sortedList = BuildSortIndex(baseList,reportSettings.GroupColumnCollection);
var unsortedList = this.BuildIndexInternal(baseList,reportSettings.GroupColumnCollection);
ShowIndexList(unsortedList);
// newList = GroupTestOne(unsortedList);
newList = GroupTestLinq(sortedList);
ShowGrouping(newList);
groupEnumerator = newList.GetEnumerator();
groupEnumerator.MoveNext();
listEnumerator = groupEnumerator.Current.GetEnumerator();
listEnumerator.MoveNext();
// Current_test = listEnumerator.Current;
// return baseList[((BaseComparer)IndexList[CurrentPosition]).ListIndex];
Current_test = baseList[listEnumerator.Current.ListIndex];
Console.WriteLine("--------Display output-----");
}
// http://stackoverflow.com/questions/5013710/linq-order-by-group-by-and-order-by-each-group?rq=1
IEnumerable<IGrouping<object, BaseComparer>> GroupOrderByRandomInt (IndexList list) {
SortColumnCollection sc = new SortColumnCollection();
sc.Add(new SortColumn("RandomInt", ListSortDirection.Ascending));
return list.GroupBy(a => a.ObjectArray[0]);
}
IEnumerable<IGrouping<object, BaseComparer>> GroupTestLinq (IndexList list) {
return (from car in list
group car by car.ObjectArray[0]);
}
/*
void Group_test(IndexList unsortedList)
{
Console.WriteLine("-------New group --------\t");
var dictionary = BuildGroup_1(unsortedList, reportSettings.GroupColumnCollection);
// foreach (var element in dictionary) {
// Console.WriteLine("{0} - {1}", element.Key, element.Value.Count);
// }
var list = dictionary.Keys.ToList();
list.Sort();
Console.WriteLine("-------Sorted keys --------");
foreach (var key in list) {
Console.WriteLine("{0}: {1}", key, dictionary[key].Count);
foreach (var element in dictionary[key]) {
Console.WriteLine("\t{0} ", ((BaseComparer)element).ObjectArray[0].ToString());
}
}
Console.WriteLine("-------Sort list by RandomInt --------");
SortColumnCollection sc = new SortColumnCollection();
sc.Add(new SortColumn("RandomInt", ListSortDirection.Ascending));
foreach (var key in list) {
Console.WriteLine("{0}: {1}", key, dictionary[key].Count);
DataCollection<object> newSource = new DataCollection<object>(elementType);
IndexList myList = new IndexList();
foreach (var element in dictionary[key]) {
newSource.Add(baseList[element.ListIndex]);
myList = BuildSortIndex(newSource,sc);
Console.WriteLine("\t{0} ", ((BaseComparer)element).ObjectArray[0].ToString());
}
dictionary[key] = myList;
// dictionary[key] = myList.OrderBy(a => a.ObjectArray[0]).ToList();
}
Console.WriteLine("Result");
foreach (var key in list) {
Console.WriteLine("{0}: {1}", key, dictionary[key].Count);
foreach (var element in dictionary[key]) {
Console.WriteLine("\t{0} ", ((BaseComparer)element).ObjectArray[0].ToString());
}
}
}
*/
/*
private IndexList BuildGroup (IndexList source,GroupColumnCollection groups)
{
string compareValue = String.Empty;
var idlist = new IndexList();
PropertyDescriptor[] groupProperties = BuildSortProperties (groups);
GroupComparer groupComparer = null;
foreach (BaseComparer element in source) {
var groupValue = ExtractValue(element,groupProperties);
var query2 = idlist.FirstOrDefault( s => ((GroupComparer)s).ObjectArray[0] == groupValue) as GroupComparer;
if (query2 == null) {
groupComparer = CreateGroupHeader(element);
idlist.Add(groupComparer);
} else {
Console.WriteLine("xx");
}
if (compareValue != groupValue) {
groupComparer = CreateGroupHeader(element);
idlist.Add(groupComparer);
}
groupComparer.IndexList.Add(element);
compareValue = groupValue;
}
ShowGrouping(ref idlist);
return idlist;
}
*/
/*
void ShowGrouping(ref IndexList idlist)
{
Console.WriteLine("----ShowGrouping---");
foreach (GroupComparer el in idlist) {
Console.WriteLine("{0}", el.ToString());
if (el.IndexList.Any()) {
foreach (var element in el.IndexList) {
Console.WriteLine("--{0}", element.ToString());
}
}
}
}
*/
string ExtractValue(BaseComparer element,PropertyDescriptor[] groupProperties)
{
var rowItem = baseList[element.ListIndex];
var values = FillComparer(groupProperties, rowItem);
// return element.ObjectArray[0].ToString();
return values[0].ToString();
}
static GroupComparer CreateGroupHeader (BaseComparer sc)
{
var gc = new GroupComparer(sc.ColumnCollection,sc.ListIndex,sc.ObjectArray);
gc.IndexList = new IndexList();
return gc;
}
#endregion
#region BuildIndexList
DataCollection<object> CreateBaseList(IEnumerable source, Type elementType)
{
var list = new DataCollection<object>(elementType);
list.AddRange(source);
return list;
}
IndexList BuildSortIndex(DataCollection<object> listToSort,Collection<AbstractColumn> sortColumnsCollection)
{
IndexList indexList = BuildIndexInternal(listToSort,sortColumnsCollection);
if (indexList[0].ObjectArray.GetLength(0) == 1) {
IEnumerable<BaseComparer> sortedList = GenericSorter (indexList);
indexList.Clear();
indexList.AddRange(sortedList);
}
else {
indexList.Sort();
}
return indexList;
}
IndexList BuildIndexInternal(DataCollection<object> listToSort,Collection<AbstractColumn> sortColumnsCollection)
{
var indexList = new IndexList();
PropertyDescriptor[] sortProperties = BuildSortProperties(sortColumnsCollection);
for (int rowIndex = 0; rowIndex < listToSort.Count; rowIndex++) {
var rowItem = listToSort[rowIndex];
var values = FillComparer(sortProperties, rowItem);
indexList.Add(new SortComparer(sortColumnsCollection, rowIndex, values));
}
return indexList;
}
#endregion
#region Sorting delegates
public void Sort()
{
if ((this.reportSettings.SortColumnsCollection != null)) {
if (this.reportSettings.SortColumnsCollection.Count > 0) {
IndexList = this.BuildSortIndex (baseList,reportSettings.SortColumnsCollection);
} else {
IndexList = this.BuildIndexInternal(baseList,reportSettings.SortColumnsCollection);
}
}
}
static IEnumerable<BaseComparer> GenericSorter (List<BaseComparer> list)
{
List<BaseComparer> sortedList = null;
ListSortDirection sortDirection = GetSortDirection(list);
sortedList = sortDirection == ListSortDirection.Ascending ? list.AsQueryable().AscendingOrder().ToList() : list.AsQueryable().DescendingOrder().ToList();
return sortedList;
}
static ListSortDirection GetSortDirection(List<BaseComparer> list)
{
BaseComparer bc = list[0];
var sortColumn = bc.ColumnCollection[0] as SortColumn;
ListSortDirection sd = sortColumn.SortDirection;
return sd;
}
Object[] FillComparer(PropertyDescriptor[] sortProperties, object rowItem)
{
object[] values = new object[sortProperties.Length];
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++) {
object value = sortProperties[criteriaIndex].GetValue(rowItem);
if (value != null && value != DBNull.Value) {
if (!(value is IComparable)) {
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
}
}
return values;
}
private PropertyDescriptor[] BuildSortProperties (Collection<AbstractColumn> sortColumnCollection)
{
var sortProperties = new PropertyDescriptor[sortColumnCollection.Count];
var descriptorCollection = this.baseList.GetItemProperties(null);
for (var criteriaIndex = 0; criteriaIndex < sortColumnCollection.Count; criteriaIndex++){
var descriptor = descriptorCollection.Find (sortColumnCollection[criteriaIndex].ColumnName,true);
if (descriptor == null){
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
"Die Liste enthält keine Spalte [{0}].",
sortColumnCollection[criteriaIndex].ColumnName));
}
sortProperties[criteriaIndex] = descriptor;
}
return sortProperties;
}
// BaseComparer GetComparer(int position)
// {
// var bc = (BaseComparer)IndexList[position];
// return bc;
// }
#endregion
#region Debug Code
private static void ShowIndexList (IndexList list)
{
Console.WriteLine("ShowIndexList");
foreach (BaseComparer element in list) {
Console.WriteLine("\t...{0} - {1}",((BaseComparer)element).ListIndex.ToString(),
((BaseComparer)element).ObjectArray[0].ToString());
}
}
static void ShowGrouping(IEnumerable<IGrouping<object, BaseComparer>> grouping)
{
Console.WriteLine("----------ShowGrouping-----------");
foreach (var element in grouping) {
Console.WriteLine("{0} - {1} ", element.Key.ToString(), element.Key is BaseComparer);
foreach (var xx in element) {
Console.WriteLine("...{0}", ((BaseComparer)xx).ObjectArray[0].ToString());
}
}
}
// static string WrongColumnName(string propertyName)
// {
// return String.Format(CultureInfo.InvariantCulture, "Error : <{0}> missing!", propertyName);
// }
#endregion
public void Reset()
{
throw new NotImplementedException();
}
}
}

6
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs

@ -30,9 +30,9 @@ namespace ICSharpCode.Reporting.Expressions.Irony.Imports @@ -30,9 +30,9 @@ namespace ICSharpCode.Reporting.Expressions.Irony.Imports
if (FieldExist(dataSource.CurrentList[0],fieldName)) {
sum = dataSource.CurrentList.Sum(o => {
var pp = o.ParsePropertyPath(fieldName);
var value = pp.Evaluate(o);
return TypeNormalizer.EnsureType<double>(value);
var propertyPath = o.ParsePropertyPath(fieldName);
var val = propertyPath.Evaluate(o);
return TypeNormalizer.EnsureType<double>(val);
});
}
return sum;

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

@ -65,7 +65,6 @@ @@ -65,7 +65,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="src\DataSource\ContributorsList.cs" />
<Compile Include="src\DataSource\CollectionHandlingFixture.cs" />
<Compile Include="src\DataSource\DataSourceFixture.cs" />
<Compile Include="src\Expressions\Aggregates\AggregateFuctionHelper.cs" />
<Compile Include="src\Expressions\Aggregates\SumAggregate.cs" />

226
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs

@ -1,226 +0,0 @@ @@ -1,226 +0,0 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 20.05.2013
* Time: 18:15
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.ComponentModel;
using System.Linq;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.Interfaces;
using ICSharpCode.Reporting.Items;
using NUnit.Framework;
namespace ICSharpCode.Reporting.Test.DataSource
{
[TestFixture]
public class CollectionHandlingFixture
{
private ContributorCollection list;
[Test]
public void CanInitDataCollection()
{
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
Assert.That(collectionSource,Is.Not.Null);
}
[Test]
public void CurrentpositionShouldZeroAfterBind () {
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind();
Assert.That(collectionSource.CurrentPosition,Is.EqualTo(0));
}
[Test]
public void CurrentPositionIsTwo () {
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind();
collectionSource.MoveNext();
collectionSource.MoveNext();
Assert.That(collectionSource.CurrentPosition,Is.EqualTo(2));
}
[Test]
public void CollectionCountIsEqualToListCount() {
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
Assert.That(collectionSource.Count,Is.EqualTo(list.Count));
}
[Test]
public void AvailableFieldsEqualContibutorsPropertyCount() {
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
Assert.That(collectionSource.AvailableFields.Count,Is.EqualTo(6));
}
#region Fill
[Test]
public void TypeOfReportItemIsString () {
var ric = new System.Collections.Generic.List<IPrintableObject>(){
new BaseDataItem(){
ColumnName = "Lastname"
},
new BaseDataItem(){
ColumnName = "Firstname"
}
};
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind();
collectionSource.Fill(ric);
foreach (BaseDataItem element in ric) {
Assert.That(element.DataType,Is.EqualTo("System.String"));
}
}
[Test]
public void FillReportItemCollection () {
var ric = new System.Collections.Generic.List<IPrintableObject>(){
new BaseDataItem(){
ColumnName = "Lastname"
},
new BaseDataItem(){
ColumnName = "Firstname"
}
};
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind();
collectionSource.Fill(ric);
foreach (BaseDataItem element in ric) {
Assert.That(element.DBValue,Is.Not.EqualTo(String.Empty));
}
}
#endregion
#region Grouping
/*
[Test]
public void GroupbyOneColumn () {
var rs = new ReportSettings();
rs.GroupColumnCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending));
var collectionSource = new CollectionSource (list,typeof(Contributor),rs);
collectionSource.Bind();
}
[Test]
public void GroupbyOneColumnAndFill () {
var ric = new System.Collections.Generic.List<IPrintableObject>(){
new BaseDataItem(){
ColumnName = "Lastname"
},
new BaseDataItem(){
ColumnName = "Firstname"
},
new BaseDataItem(){
ColumnName = "GroupItem"
},
new BaseDataItem(){
ColumnName = "RandomInt"
}
};
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 CollectionSource (list,typeof(Contributor),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);
i ++;
}while (collectionSource.MoveNext());
Assert.That(i,Is.EqualTo(collectionSource.Count));
}
*/
#endregion
#region Sort
[Test]
public void CreateUnsortedIndex() {
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind();
Assert.That(collectionSource.IndexList.Count,Is.EqualTo(collectionSource.Count));
Assert.That(collectionSource.IndexList.CurrentPosition,Is.EqualTo(0));
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void SortColumnNotExist() {
var rs = new ReportSettings();
rs.SortColumnsCollection.Add(new SortColumn("aa",ListSortDirection.Ascending));
var collectionSource = new CollectionSource (list,typeof(Contributor),rs);
collectionSource.Bind();
Assert.That(collectionSource.IndexList,Is.Not.Null);
Assert.That(collectionSource.IndexList.Count,Is.EqualTo(0));
}
[Test]
public void SortOneColumnAscending() {
var rs = new ReportSettings();
rs.SortColumnsCollection.Add(new SortColumn("Lastname",ListSortDirection.Ascending));
var collectionSource = new CollectionSource (list,typeof(Contributor),rs);
collectionSource.Bind();
string compare = collectionSource.IndexList[0].ObjectArray[0].ToString();
foreach (var element in collectionSource.IndexList) {
string result = String.Format("{0} - {1}",element.ListIndex,element.ObjectArray[0]);
// Coole.WriteLine(result);
Assert.That(compare,Is.LessThanOrEqualTo(element.ObjectArray[0].ToString()));
compare = element.ObjectArray[0].ToString();
}
}
[Test]
public void SortTwoColumnsAscending() {
var rs = new ReportSettings();
rs.SortColumnsCollection.Add(new SortColumn("Lastname",ListSortDirection.Ascending));
rs.SortColumnsCollection.Add(new SortColumn("RandomInt",ListSortDirection.Ascending));
var collectionSource = new CollectionSource (list,typeof(Contributor),rs);
collectionSource.Bind();
string compare = collectionSource.IndexList[0].ObjectArray[0].ToString();
foreach (var element in collectionSource.IndexList) {
string result = String.Format("{0} - {1} - {2}",element.ListIndex,element.ObjectArray[0],element.ObjectArray[1].ToString());
Console.WriteLine(result);
Assert.That(compare,Is.LessThanOrEqualTo(element.ObjectArray[0].ToString()));
compare = element.ObjectArray[0].ToString();
}
}
#endregion
[SetUp]
public void CreateList() {
var contributorList = new ContributorsList();
list = contributorList.ContributorCollection;
}
}
}

22
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -17,7 +17,7 @@ namespace ICSharpCode.Reporting.Test.DataSource
[Test]
public void CollectionCountIsEqualToListCount() {
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
var collectionSource = new CollectionDataSource (list,typeof(Contributor),new ReportSettings());
Assert.That(collectionSource.Count,Is.EqualTo(list.Count));
}
@ -39,6 +39,26 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -39,6 +39,26 @@ namespace ICSharpCode.Reporting.Test.DataSource
}
[Test]
public void TypeOfReportItemIsString () {
var ric = new System.Collections.Generic.List<IPrintableObject>(){
new BaseDataItem(){
ColumnName = "Lastname"
},
new BaseDataItem(){
ColumnName = "Firstname"
}
};
var collectionSource = new CollectionDataSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind();
collectionSource.Fill(ric);
foreach (BaseDataItem element in ric) {
Assert.That(element.DataType,Is.EqualTo("System.String"));
}
}
[Test]
public void SortOneColumnAscending() {
var ric = new System.Collections.Generic.List<IPrintableObject>(){

Loading…
Cancel
Save