[Adapdev-commits] Adapdev/src/Adapdev.Windows.Forms.Tests SmartTreeViewTest.cs,NONE,1.1 Adapdev.Wind
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-05-25 05:17:57
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10621/src/Adapdev.Windows.Forms.Tests Modified Files: Adapdev.Windows.Forms.Tests.csproj Added Files: SmartTreeViewTest.cs Log Message: MIgrated reusable Perseus components Added SmartTreeView Added new caching framework Several Sql fixes Added business rule validation classes Added FieldAccessor for IL generation Index: Adapdev.Windows.Forms.Tests.csproj =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms.Tests/Adapdev.Windows.Forms.Tests.csproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Adapdev.Windows.Forms.Tests.csproj 14 Apr 2005 03:32:06 -0000 1.3 --- Adapdev.Windows.Forms.Tests.csproj 25 May 2005 05:17:48 -0000 1.4 *************** *** 85,88 **** --- 85,108 ---- HintPath = "..\..\lib\log4net.dll" /> + <Reference + Name = "nunit.framework" + AssemblyName = "nunit.framework" + HintPath = "..\..\lib\nunit.framework.dll" + /> + <Reference + Name = "Adapdev.Windows.Forms" + Project = "{0BE602B6-D67E-414E-B852-A2AC61305E8E}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> + <Reference + Name = "System.Windows.Forms" + AssemblyName = "System.Windows.Forms" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll" + /> + <Reference + Name = "System.Drawing" + AssemblyName = "System.Drawing" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll" + /> </References> </Build> *************** *** 95,98 **** --- 115,123 ---- BuildAction = "Compile" /> + <File + RelPath = "SmartTreeViewTest.cs" + SubType = "Code" + BuildAction = "Compile" + /> </Include> </Files> --- NEW FILE: SmartTreeViewTest.cs --- using System; using System.Windows.Forms; using NUnit.Framework; using Adapdev.Windows.Forms; namespace Adapdev.Windows.Forms.Tests { using System.Drawing; /// <summary> /// Summary description for SmartTreeViewTest. /// </summary> /// [TestFixture] public class SmartTreeViewTest { SmartTreeView tree = null; [SetUp] public void BuildTree() { tree = new SmartTreeView(); TreeNode root = new TreeNode("Root"); tree.Nodes.Add(root); TreeNode node1 = new TreeNode("Node1"); TreeNode child1 = new TreeNode("Child1"); TreeNode child2 = new TreeNode("Child2"); node1.Nodes.Add(child1); node1.Nodes.Add(child2); TreeNode node2 = new TreeNode("Node2"); TreeNode child3 = new TreeNode("Child3"); TreeNode child4 = new TreeNode("Child4"); node2.Nodes.Add(child3); node2.Nodes.Add(child4); root.Nodes.Add(node1); root.Nodes.Add(node2); /* * Structure: * Root * Node1 * Child1 * Child2 * Node2 * Child3 * Child4 **/ } [Test] public void CheckParents() { // Make sure all nodes are at the proper state Assert.IsTrue(this.GetChild1().Checked == false, "Child1 should not be checked."); Assert.IsTrue(this.GetNode1().Checked == false, "Node1 should not be checked."); Assert.IsTrue(this.GetRoot().Checked == false, "Root should not be checked."); // Check the child, which should check all parents this.GetChild1().Checked = true; Assert.IsTrue(this.GetNode1().Checked, "Node1 should be checked."); Assert.IsTrue(this.GetRoot().Checked, "Root should be checked."); // Uncheck the child...parents should remain checked this.GetChild1().Checked = false; Assert.IsTrue(this.GetNode1().Checked, "Node1 should be checked."); Assert.IsTrue(this.GetRoot().Checked, "Root should be checked."); } [Test] public void CheckChildren() { // Make sure all nodes are at the proper state Assert.IsTrue(this.GetChild1().Checked == false, "Child1 should not be checked."); Assert.IsTrue(this.GetNode1().Checked == false, "Node1 should not be checked."); Assert.IsTrue(this.GetRoot().Checked == false, "Root should not be checked."); // Check the root node this.GetRoot().Checked = true; // All child nodes should be checked Assert.IsTrue(this.GetRoot().Checked, "Root should be checked."); Assert.IsTrue(this.GetNode1().Checked, "Node1 should be checked."); Assert.IsTrue(this.GetNode2().Checked, "Node2 should be checked."); Assert.IsTrue(this.GetChild1().Checked, "Child1 should be checked."); Assert.IsTrue(this.GetChild2().Checked, "Child2 should be checked."); Assert.IsTrue(this.GetChild3().Checked, "Child3 should be checked."); Assert.IsTrue(this.GetChild4().Checked, "Child4 should be checked."); // Uncheck the root node this.GetRoot().Checked = false; // All child nodes should be unchecked Assert.IsFalse(this.GetRoot().Checked, "Root should not be checked."); Assert.IsFalse(this.GetNode1().Checked, "Node1 should not be checked."); Assert.IsFalse(this.GetNode2().Checked, "Node2 should not be checked."); Assert.IsFalse(this.GetChild1().Checked, "Child1 should not be checked."); Assert.IsFalse(this.GetChild2().Checked, "Child2 should not be checked."); Assert.IsFalse(this.GetChild3().Checked, "Child3 should not be checked."); Assert.IsFalse(this.GetChild4().Checked, "Child4 should not be checked."); } [Test] public void CheckColor() { // IMPORTANT - need to set the root node checked value // Test fails otherwise, since the Color comes up // as Color.Empty this.GetRoot().Checked = false; // Node1 should be unchecked and light gray Assert.AreEqual(Color.LightGray, this.GetNode1().ForeColor, "Node1 unchecked color is incorrect."); // Root should be unchecked and light gray Assert.AreEqual(Color.LightGray, this.GetRoot().ForeColor, "Root unchecked color is incorrect."); this.GetNode1().Checked = true; // Node1 should be checked and black Assert.AreEqual(Color.Black, this.GetNode1().ForeColor); // Root should be checked and black Assert.AreEqual(Color.Black, this.GetRoot().ForeColor); } [Test] public void ValidateStructure() { Assert.AreEqual("Root", this.GetRoot().Text); Assert.AreEqual("Node1", this.GetNode1().Text); Assert.AreEqual("Node2", this.GetNode2().Text); Assert.AreEqual("Child1", this.GetChild1().Text); Assert.AreEqual("Child2", this.GetChild2().Text); Assert.AreEqual("Child3", this.GetChild3().Text); Assert.AreEqual("Child4", this.GetChild4().Text); } #region Utility Methods private TreeNode GetRoot() { return tree.Nodes[0]; } private TreeNode GetNode1() { return this.GetRoot().Nodes[0]; } private TreeNode GetNode2() { return this.GetRoot().Nodes[1]; } private TreeNode GetChild1() { return this.GetNode1().Nodes[0]; } private TreeNode GetChild2() { return this.GetNode1().Nodes[1]; } private TreeNode GetChild3() { return this.GetNode2().Nodes[0]; } private TreeNode GetChild4() { return this.GetNode2().Nodes[1]; } #endregion } } |