Skip to content

Commit b2670a1

Browse files
author
grammarian
committed
- Added more tests
git-svn-id: https://svn.code.sf.net/p/objectlistview/code/cs/trunk@799 0bec5ed8-b53f-49e6-9885-ce7bc93af311
1 parent 0ca4d40 commit b2670a1

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

Tests/MainForm.Designer.cs

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ private static string GetName(PropertyInfo pinfo) {
281281
new string[] { "GroupWithItemCountSingularFormatOrDefault", "GroupWithItemCountSingularFormat OrDefault" },
282282
new string[] { "RenderNonEditableCheckboxesAsDisabled", "RenderNonEditableCheckboxes AsDisabled" },
283283
new string[] { "UpdateSpaceFillingColumnsWhenDraggingColumnDivider", "UpdateSpaceFillingColumnsWhenDragging ColumnDivider" },
284-
new string[] { "UnfocusedHighlightForegroundColorOrDefault", "UnfocusedHighlightForegroundColorOr Default" },
285-
new string[] { "UnfocusedHighlightBackgroundColorOrDefault", "UnfocusedHighlightBackgroundColorOr Default" }
284+
new string[] { "UnfocusedSelectedForeColorOrDefault", "UnfocusedHighlightForegroundColorOr Default" },
285+
new string[] { "UnfocusedSelectedBackColorOrDefault", "UnfocusedHighlightBackgroundColorOr Default" }
286286

287287
});
288288

Tests/TestExport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* You should have received a copy of the GNU General Public License
2323
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2424
*
25-
* If you wish to use this code in a closed source application, please contact phillip_piper@bigfoot.com.
25+
* If you wish to use this code in a closed source application, please contact phillip.piper@gmail.com.
2626
*/
2727

2828
using NUnit.Framework;

Tests/TestNotifications.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* You should have received a copy of the GNU General Public License
2323
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2424
*
25-
* If you wish to use this code in a closed source application, please contact phillip_piper@bigfoot.com.
25+
* If you wish to use this code in a closed source application, please contact phillip.piper@gmail.com.
2626
*/
2727

2828
using System.Drawing;

Tests/TestTreeView.cs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
using System.Collections;
1313
using System.Collections.Generic;
1414
using System.Drawing;
15+
using System.Windows.Forms;
16+
using System.Windows.Forms.VisualStyles;
1517
using NUnit.Framework;
1618

1719
namespace BrightIdeasSoftware.Tests
@@ -51,7 +53,7 @@ public void InitEachTest() {
5153

5254
[TearDown]
5355
public void TearDownEachTest() {
54-
mainForm.Close();
56+
mainForm.Close();
5557
}
5658

5759
[Test]
@@ -485,7 +487,7 @@ public void Test_HierarchicalCheckBoxes_CheckedObjects_Set_RecalculatesParent()
485487
Assert.IsEmpty(this.olv.CheckedObjects);
486488

487489
this.olv.HierarchicalCheckboxes = true;
488-
490+
489491
this.olv.CheckedObjects = ObjectListView.EnumerableToArray(firstRoot.Children, true);
490492

491493
ArrayList checkedObjects = new ArrayList(this.olv.CheckedObjects);
@@ -495,6 +497,48 @@ public void Test_HierarchicalCheckBoxes_CheckedObjects_Set_RecalculatesParent()
495497
Assert.IsTrue(checkedObjects.Contains(child));
496498
}
497499

500+
[Test]
501+
public void Test_HierarchicalCheckBoxes_CheckedObjects_Set_DeeplyNestedObject()
502+
{
503+
this.olv.HierarchicalCheckboxes = true;
504+
Assert.IsEmpty(this.olv.CheckedObjects);
505+
506+
// The tree structure is:
507+
// GGP1
508+
// +-- GP1
509+
// +-- GP2
510+
// +-- P1
511+
// +-- last
512+
// So checking "last" will also check P1 and GP2, and will make GGP1 indeterminate.
513+
514+
Person last = PersonDb.All[PersonDb.All.Count - 1];
515+
Person P1 = last.Parent;
516+
Person GP2 = last.Parent.Parent;
517+
Person GGP1 = last.Parent.Parent.Parent;
518+
Person GP1 = GGP1.Children[0];
519+
520+
ArrayList toBeChecked = new ArrayList();
521+
toBeChecked.Add(last);
522+
this.olv.CheckedObjects = toBeChecked;
523+
524+
ArrayList checkedObjects = new ArrayList(this.olv.CheckedObjects);
525+
Assert.AreEqual(3, checkedObjects.Count);
526+
Assert.IsTrue(checkedObjects.Contains(last));
527+
Assert.IsTrue(checkedObjects.Contains(P1));
528+
Assert.IsTrue(checkedObjects.Contains(GP2));
529+
Assert.IsFalse(checkedObjects.Contains(GGP1));
530+
531+
Assert.IsTrue(this.olv.IsChecked(last));
532+
Assert.IsTrue(this.olv.IsChecked(P1));
533+
Assert.IsTrue(this.olv.IsChecked(GP2));
534+
Assert.IsTrue(this.olv.IsCheckedIndeterminate(GGP1));
535+
536+
// When GP1 is checked, GGP1 should also become checked.
537+
this.olv.CheckObject(GP1);
538+
Assert.IsTrue(this.olv.IsChecked(GP1));
539+
Assert.IsTrue(this.olv.IsChecked(GGP1));
540+
}
541+
498542
[Test]
499543
public void Test_HierarchicalCheckBoxes_CheckedObjects_Set_ClearsPreviousChecks() {
500544
Person firstRoot = PersonDb.All[0];

0 commit comments

Comments
 (0)