Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
More test's for IList Grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterForstmeier committed Sep 10, 2010
1 parent 38837e3 commit 13f7db4
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 100 deletions.
Expand Up @@ -239,7 +239,11 @@ public static void EvaluateRow(IExpressionEvaluatorFacade evaluator,ExporterColl
ExportText textItem = element as ExportText;

if (textItem != null) {
textItem.Text = evaluator.Evaluate(textItem.Text);

string s = evaluator.Evaluate(textItem.Text);
Console.WriteLine("\teval {0} - {1} ",textItem.Text,s);
// textItem.Text = evaluator.Evaluate(textItem.Text);
textItem.Text = s;
}
}
}
Expand Down
Expand Up @@ -162,9 +162,9 @@ public void FillChild (ReportItemCollection collection)

private IndexList BuildChildList()
{
var t = store as TableStrategy;
IndexList i = t.IndexList;
GroupComparer gc = i[t.CurrentPosition] as GroupComparer;

IndexList i = store.IndexList;
GroupComparer gc = i[store.CurrentPosition] as GroupComparer;
if (gc == null) {
return null;
}
Expand Down
Expand Up @@ -74,7 +74,6 @@ public IndexList IndexList
protected ReportSettings ReportSettings {get;private set;}



#region Sorting delegates

protected static List<BaseComparer> GenericSorter (List<BaseComparer> list)
Expand All @@ -94,8 +93,32 @@ protected static List<BaseComparer> GenericSorter (List<BaseComparer> list)

#endregion


#region Grouping

protected void BuildGroup (IndexList list)
{
string compVal = String.Empty;
IndexList.Clear();
IndexList childList = null;
BaseComparer checkElem = list[0];
foreach (BaseComparer element in list)
{
string v = element.ObjectArray[0].ToString();
if (compVal != v) {
childList = new IndexList();
GroupComparer gc = CreateGroupHeader(element);
gc.IndexList = childList;
CreateGroupeChildren(childList,element);
} else {
CreateGroupeChildren(childList,element);
}
compVal = v;
}
ShowIndexList(IndexList);
}


protected GroupComparer CreateGroupHeader (BaseComparer sc)
{
GroupComparer gc = new GroupComparer(sc.ColumnCollection,sc.ListIndex,sc.ObjectArray);
Expand All @@ -109,6 +132,7 @@ protected void CreateGroupeChildren(IndexList list,BaseComparer sc)
string v = sc.ObjectArray[0].ToString();
list.Add(sc);
}

#endregion

#region Debug Code
Expand Down
Expand Up @@ -164,54 +164,17 @@ public override int CurrentPosition
}
}


public override void Group ()
{
base.Group();
IndexList gl = new IndexList("group");
gl = this.BuildSortIndex (ReportSettings.GroupColumnsCollection);
ShowIndexList(gl);
BuildGroup(gl);
}


private void BuildGroup (IndexList list)
{
string compVal = String.Empty;
base.IndexList.Clear();
IndexList childList = null;
BaseComparer checkElem = list[0];
foreach (BaseComparer element in list)
{
string v = element.ObjectArray[0].ToString();
if (compVal != v) {
childList = new IndexList();
GroupComparer gc = base.CreateGroupHeader(element);
gc.IndexList = childList;

CreateGroupeChildren(childList,element);
} else {
CreateGroupeChildren(childList,element);
}
compVal = v;
}
ShowIndexList(base.IndexList);
}

/*
private GroupComparer BuildGroupHeader (BaseComparer sc)
{
GroupComparer gc = new GroupComparer(sc.ColumnCollection,sc.ListIndex,sc.ObjectArray);
base.IndexList.Add(gc);
return gc;
base.BuildGroup(gl);
}


private void GChild(IndexList list,BaseComparer sc)
{
string v = sc.ObjectArray[0].ToString();
list.Add(sc);
}
*/
public override void Sort()
{
base.Sort();
Expand All @@ -228,8 +191,6 @@ public override void Sort()
}




public override void Reset()
{
this.CurrentPosition = 0;
Expand All @@ -248,6 +209,8 @@ public override void Bind()
Reset();
}

#endregion

public override void Fill(IDataItem item)
{
if (current != null) {
Expand Down Expand Up @@ -315,21 +278,7 @@ public override CurrentItemsCollection FillDataRow()
}

#endregion

/*
protected override void Group()
{
if (base.ReportSettings.GroupColumnsCollection.Count == 0) {
return;
}
this.BuildGroup();
base.Group();
}
*/

#endregion


#region IDisposable

public override void Dispose(){
Expand Down
Expand Up @@ -149,45 +149,6 @@ private IndexList BuildSortIndex(ColumnCollection col)
return arrayList;
}


private void BuildGroup (IndexList list)
{
string compVal = String.Empty;
base.IndexList.Clear();
IndexList childList = null;
BaseComparer checkElem = list[0];
foreach (BaseComparer element in list)
{
string v = element.ObjectArray[0].ToString();
if (compVal != v) {
childList = new IndexList();
GroupComparer gc = base.CreateGroupHeader(element);
gc.IndexList = childList;
CreateGroupeChildren(childList,element);
} else {
CreateGroupeChildren(childList,element);
}
compVal = v;
}
ShowIndexList(base.IndexList);
}


// private GroupComparer CreateGroupHeader (BaseComparer sc)
// {
// GroupComparer gc = new GroupComparer(sc.ColumnCollection,sc.ListIndex,sc.ObjectArray);
// base.IndexList.Add(gc);
// return gc;
// }

/*
private void CreateGroupeChildren(IndexList list,BaseComparer sc)
{
string v = sc.ObjectArray[0].ToString();
list.Add(sc);
}
*/

private IndexList IndexBuilder(SortColumnCollection col)
{
Expand Down
Expand Up @@ -19,6 +19,8 @@ public interface IDataViewStrategy:IEnumerator,IDisposable{
void Bind();

void Fill (IDataItem item);

IndexList IndexList {get;}
//test
CurrentItemsCollection FillDataRow();
//
Expand Down
Expand Up @@ -39,6 +39,32 @@ public void GroupingCollection_Contains_IsGrouped_True()
}


#region group by StringValue

[Test]
public void Has_Children()
{
var dataNav = PrepareStringGrouping();
while (dataNav.MoveNext()) {
Assert.That(dataNav.HasChildren,Is.True);
}
}


[Test]
public void Can_Read_Child_Count ()
{
var dataNav = PrepareStringGrouping();
while (dataNav.MoveNext())
{
Assert.That(dataNav.ChildListCount,Is.GreaterThan(0));
}
}


#endregion


private IDataNavigator PrepareStringGrouping ()
{
GroupColumn gc = new GroupColumn("GroupItem",1,ListSortDirection.Ascending);
Expand Down

0 comments on commit 13f7db4

Please sign in to comment.