Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests that show Tree control maintains checked/collapsed state #593

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
984e734
Adding tests to prove that the load function works as expected
StanleyGoldman Feb 26, 2018
86df31e
Merge branch 'fixes/ignore-test' into fixes/tree-load-collapsed-nodes
StanleyGoldman Feb 27, 2018
2be49ed
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman Mar 7, 2018
0c84165
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman Mar 29, 2018
0d24a4d
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman Apr 5, 2018
2ec98e9
Merge branch 'master' into fixes/tree-load-collapsed-nodes
shana Apr 9, 2018
fbf76c4
Merge branch 'master' into fixes/tree-load-collapsed-nodes
shana Apr 9, 2018
bbe7962
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman Apr 19, 2018
3034f9a
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman May 4, 2018
67f9d06
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman May 4, 2018
2fef119
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman May 9, 2018
bd352cd
Merge branch 'master' into fixes/tree-load-collapsed-nodes
shana May 10, 2018
2cecbb5
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman May 10, 2018
7b41fc2
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman May 15, 2018
7131936
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman May 21, 2018
6d2e193
Merge branch 'master' into fixes/tree-load-collapsed-nodes
StanleyGoldman Dec 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
385 changes: 385 additions & 0 deletions src/tests/UnitTests/UI/TreeBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,5 +1188,390 @@ public void ShouldPopulateTreeWithMixOfEntries()
}
});
}

[Test]
public void ShouldLoadCollapsedTreeNode()
{
var testTree = new TestTree(true);
var testTreeListener = testTree.TestTreeListener;

testTreeListener.GetCollapsedFolders().Returns(new[] { "BFolder" });
testTreeListener.SelectedNode.Returns((TestTreeNode)null);
testTreeListener.GetCheckedFiles().Returns(new string[0]);
testTreeListener.Nodes.Returns(new List<TestTreeNode>());
testTreeListener.PathSeparator.Returns(@"\");
testTreeListener.DisplayRootNode.Returns(false);
testTreeListener.IsSelectable.Returns(false);
testTreeListener.Title.Returns("Test Tree");

var testTreeData = new[] {
new TestTreeData {
Path = "AFile.txt"
},
new TestTreeData {
Path = "BFolder\\test.txt"
},
new TestTreeData {
Path = "BFolder\\SubFolder\\test.txt"
},
new TestTreeData {
Path = "CFolder\\test.txt"
},
new TestTreeData {
Path = "DFile.txt"
},
};
testTree.Load(testTreeData);

testTree.CreatedTreeNodes.ShouldAllBeEquivalentTo(new[] {
new TestTreeNode {
Path = "Test Tree",
Label = "Test Tree",
IsFolder = true,
Level = -1
},
new TestTreeNode {
Path = "AFile.txt",
Label = "AFile.txt",
Level = 0,
TreeData = testTreeData[0]
},
new TestTreeNode {
Path = "BFolder",
Label = "BFolder",
Level = 0,
IsCollapsed = true,
IsFolder = true
},
new TestTreeNode {
Path = "BFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[1],
IsHidden = true
},
new TestTreeNode {
Path = "BFolder\\SubFolder",
Label = "SubFolder",
Level = 1,
IsFolder = true,
IsHidden = true
},
new TestTreeNode {
Path = "BFolder\\SubFolder\\test.txt",
Label = "test.txt",
Level = 2,
TreeData = testTreeData[2],
IsHidden = true
},
new TestTreeNode {
Path = "CFolder",
Label = "CFolder",
Level = 0,
IsFolder = true
},
new TestTreeNode {
Path = "CFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[3]
},
new TestTreeNode {
Path = "DFile.txt",
Label = "DFile.txt",
Level = 0,
TreeData = testTreeData[4]
}
});
}

[Test]
public void ShouldLoadTreeWithCheckedNode()
{
var testTree = new TestTree(true) {
IsCheckable = true
};
var testTreeListener = testTree.TestTreeListener;

testTreeListener.GetCollapsedFolders().Returns(new string[0]);
testTreeListener.SelectedNode.Returns((TestTreeNode)null);
testTreeListener.GetCheckedFiles().Returns(new[] { "AFile.txt" });
testTreeListener.Nodes.Returns(new List<TestTreeNode>());
testTreeListener.PathSeparator.Returns(@"\");
testTreeListener.DisplayRootNode.Returns(false);
testTreeListener.IsSelectable.Returns(false);
testTreeListener.Title.Returns("Test Tree");

var testTreeData = new[] {
new TestTreeData {
Path = "AFile.txt"
},
new TestTreeData {
Path = "BFolder\\test.txt"
},
new TestTreeData {
Path = "BFolder\\SubFolder\\test.txt"
},
new TestTreeData {
Path = "CFolder\\test.txt"
},
new TestTreeData {
Path = "DFile.txt"
},
};
testTree.Load(testTreeData);

testTree.CreatedTreeNodes.ShouldAllBeEquivalentTo(new[] {
new TestTreeNode {
Path = "Test Tree",
Label = "Test Tree",
IsFolder = true,
Level = -1
},
new TestTreeNode {
Path = "AFile.txt",
Label = "AFile.txt",
Level = 0,
TreeData = testTreeData[0],
CheckState = CheckState.Checked
},
new TestTreeNode {
Path = "BFolder",
Label = "BFolder",
Level = 0,
IsFolder = true
},
new TestTreeNode {
Path = "BFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[1]
},
new TestTreeNode {
Path = "BFolder\\SubFolder",
Label = "SubFolder",
Level = 1,
IsFolder = true
},
new TestTreeNode {
Path = "BFolder\\SubFolder\\test.txt",
Label = "test.txt",
Level = 2,
TreeData = testTreeData[2]
},
new TestTreeNode {
Path = "CFolder",
Label = "CFolder",
Level = 0,
IsFolder = true
},
new TestTreeNode {
Path = "CFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[3]
},
new TestTreeNode {
Path = "DFile.txt",
Label = "DFile.txt",
Level = 0,
TreeData = testTreeData[4]
}
});
}

[Test]
public void ShouldLoadTreeWithCheckedFolderNode()
{
var testTree = new TestTree(true) {
IsCheckable = true
};
var testTreeListener = testTree.TestTreeListener;

testTreeListener.GetCollapsedFolders().Returns(new string[0]);
testTreeListener.SelectedNode.Returns((TestTreeNode)null);
testTreeListener.GetCheckedFiles().Returns(new[] { "BFolder\\test.txt" });
testTreeListener.Nodes.Returns(new List<TestTreeNode>());
testTreeListener.PathSeparator.Returns(@"\");
testTreeListener.DisplayRootNode.Returns(false);
testTreeListener.IsSelectable.Returns(false);
testTreeListener.Title.Returns("Test Tree");

var testTreeData = new[] {
new TestTreeData {
Path = "AFile.txt"
},
new TestTreeData {
Path = "BFolder\\test.txt"
},
new TestTreeData {
Path = "BFolder\\SubFolder\\test.txt"
},
new TestTreeData {
Path = "CFolder\\test.txt"
},
new TestTreeData {
Path = "DFile.txt"
},
};
testTree.Load(testTreeData);

testTree.CreatedTreeNodes.ShouldAllBeEquivalentTo(new[] {
new TestTreeNode {
Path = "Test Tree",
Label = "Test Tree",
IsFolder = true,
Level = -1
},
new TestTreeNode {
Path = "AFile.txt",
Label = "AFile.txt",
Level = 0,
TreeData = testTreeData[0]
},
new TestTreeNode {
Path = "BFolder",
Label = "BFolder",
Level = 0,
IsFolder = true,
CheckState = CheckState.Mixed
},
new TestTreeNode {
Path = "BFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[1],
CheckState = CheckState.Checked
},
new TestTreeNode {
Path = "BFolder\\SubFolder",
Label = "SubFolder",
Level = 1,
IsFolder = true
},
new TestTreeNode {
Path = "BFolder\\SubFolder\\test.txt",
Label = "test.txt",
Level = 2,
TreeData = testTreeData[2]
},
new TestTreeNode {
Path = "CFolder",
Label = "CFolder",
Level = 0,
IsFolder = true
},
new TestTreeNode {
Path = "CFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[3]
},
new TestTreeNode {
Path = "DFile.txt",
Label = "DFile.txt",
Level = 0,
TreeData = testTreeData[4]
}
});
}

[Test]
public void ShouldLoadTreeWithCheckedFolderNode2()
{
var testTree = new TestTree(true)
{
IsCheckable = true
};
var testTreeListener = testTree.TestTreeListener;

testTreeListener.GetCollapsedFolders().Returns(new string[0]);
testTreeListener.SelectedNode.Returns((TestTreeNode)null);
testTreeListener.GetCheckedFiles().Returns(new[] { "BFolder\\SubFolder\\test.txt" });
testTreeListener.Nodes.Returns(new List<TestTreeNode>());
testTreeListener.PathSeparator.Returns(@"\");
testTreeListener.DisplayRootNode.Returns(false);
testTreeListener.IsSelectable.Returns(false);
testTreeListener.Title.Returns("Test Tree");

var testTreeData = new[] {
new TestTreeData {
Path = "AFile.txt"
},
new TestTreeData {
Path = "BFolder\\test.txt"
},
new TestTreeData {
Path = "BFolder\\SubFolder\\test.txt"
},
new TestTreeData {
Path = "CFolder\\test.txt"
},
new TestTreeData {
Path = "DFile.txt"
},
};
testTree.Load(testTreeData);

testTree.CreatedTreeNodes.ShouldAllBeEquivalentTo(new[] {
new TestTreeNode {
Path = "Test Tree",
Label = "Test Tree",
IsFolder = true,
Level = -1
},
new TestTreeNode {
Path = "AFile.txt",
Label = "AFile.txt",
Level = 0,
TreeData = testTreeData[0]
},
new TestTreeNode {
Path = "BFolder",
Label = "BFolder",
Level = 0,
IsFolder = true,
CheckState = CheckState.Mixed
},
new TestTreeNode {
Path = "BFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[1]
},
new TestTreeNode {
Path = "BFolder\\SubFolder",
Label = "SubFolder",
Level = 1,
IsFolder = true,
CheckState = CheckState.Checked
},
new TestTreeNode {
Path = "BFolder\\SubFolder\\test.txt",
Label = "test.txt",
Level = 2,
TreeData = testTreeData[2],
CheckState = CheckState.Checked
},
new TestTreeNode {
Path = "CFolder",
Label = "CFolder",
Level = 0,
IsFolder = true
},
new TestTreeNode {
Path = "CFolder\\test.txt",
Label = "test.txt",
Level = 1,
TreeData = testTreeData[3]
},
new TestTreeNode {
Path = "DFile.txt",
Label = "DFile.txt",
Level = 0,
TreeData = testTreeData[4]
}
});
}
}
}