public void TreeView_ViewStateNodes () { PokerTreeView tv = new PokerTreeView (); TreeNode R = new TreeNode ("root", "value-root"); TreeNode N1 = new TreeNode ("node1", "value-node1"); TreeNode N2 = new TreeNode ("node2", "value-node2"); R.ChildNodes.Add (N1); R.ChildNodes.Add (N2); tv.Nodes.Add (R); PokerTreeView copy = new PokerTreeView (); object state = tv.SaveState (); copy.LoadState (state); Assert.AreEqual (1, tv.Nodes.Count, "ViewStateNodes-1"); Assert.AreEqual (2, tv.Nodes[0].ChildNodes.Count, "ViewStateNodes-1"); Assert.AreEqual (0, tv.Nodes[0].ChildNodes[0].ChildNodes.Count, "ViewStateNodes-2"); Assert.AreEqual ("node1", tv.Nodes[0].ChildNodes[0].Text, "ViewStateNodes-3"); Assert.AreEqual ("value-node1", tv.Nodes[0].ChildNodes[0].Value, "ViewStateNodes-4"); Assert.AreEqual (false, tv.Nodes[0].ChildNodes[0].DataBound, "ViewStateNodes-5"); Assert.AreEqual ("", tv.Nodes[0].ChildNodes[0].DataPath, "ViewStateNodes-6"); }
public void TreeView_ViewStateDataBoundNodes () { PokerTreeView b = new PokerTreeView (); SetDataBindings (b); b.DataSource = CreateXmlDataSource (); b.DataBind (); PokerTreeView copy = new PokerTreeView (); object state = b.SaveState (); copy.LoadState (state); CheckTreeNodes (copy); }
public void Treeview_ViewState () { PokerTreeView tv = new PokerTreeView (); tv.AutoGenerateDataBindings = true; Assert.AreEqual (true, tv.AutoGenerateDataBindings, "AutoGenerateDataBindings-beforecopy"); TreeNode node = new TreeNode (); node.Checked = true; tv.Nodes.Add (node); tv.Nodes.Add (new TreeNode ()); Assert.AreEqual (2, tv.Nodes.Count, "Nodes-beforecopy"); Assert.AreEqual (1, tv.CheckedNodes.Count, "CheckedNodes-beforecopy"); tv.CollapseImageToolTip = "Collapse {0}"; Assert.AreEqual ("Collapse {0}", tv.CollapseImageToolTip, "CollapseImageToolTip-beforecopy"); tv.CollapseImageUrl = string.Empty; Assert.AreEqual (string.Empty, tv.CollapseImageUrl, "CollapseImageUrl-beforecopy"); tv.DataBindings.Add (new TreeNodeBinding ()); Assert.AreEqual (1, tv.DataBindings.Count, "DataBindings-beforecopy"); tv.EnableClientScript = true; Assert.AreEqual (true, tv.EnableClientScript, "EnableClientScript-beforecopy"); tv.ExpandDepth = -1; Assert.AreEqual (-1, tv.ExpandDepth, "ExpandDepth-beforecopy"); tv.ExpandImageToolTip = "Expand {0}"; Assert.AreEqual ("Expand {0}", tv.ExpandImageToolTip, "ExpandImageToolTip-beforecopy"); tv.ExpandImageUrl = string.Empty; Assert.AreEqual (string.Empty, tv.ExpandImageUrl, "ExpandImageUrl-beforecopy"); tv.ImageSet = TreeViewImageSet.Custom; Assert.AreEqual (TreeViewImageSet.Custom, tv.ImageSet, "ImageSet-beforecopy"); tv.LevelStyles.Add (new TreeNodeStyle ()); Assert.AreEqual (1, tv.LevelStyles.Count, "LevelStyles-beforecopy"); tv.LineImagesFolder = string.Empty; Assert.AreEqual (string.Empty, tv.LineImagesFolder, "LineImagesFolder-beforecopy"); tv.MaxDataBindDepth = -1; Assert.AreEqual (-1, tv.MaxDataBindDepth, "MaxDataBindDepth-beforecopy"); tv.NodeIndent = 20; Assert.AreEqual (20, tv.NodeIndent, "NodeIndent-beforecopy"); tv.NodeWrap = false; Assert.AreEqual (false, tv.NodeWrap, "NodeWrap-beforecopy"); tv.NoExpandImageUrl = string.Empty; Assert.AreEqual (string.Empty, tv.NoExpandImageUrl, "NoExpandImageUrl-beforecopy"); tv.PopulateNodesFromClient = true; Assert.AreEqual (true, tv.PopulateNodesFromClient, "PopulateNodesFromClient-beforecopy"); tv.ShowCheckBoxes = TreeNodeTypes.None; Assert.AreEqual (TreeNodeTypes.None, tv.ShowCheckBoxes, "ShowCheckBoxes-beforecopy"); tv.ShowExpandCollapse = true; Assert.AreEqual (true, tv.ShowExpandCollapse, "ShowExpandCollapse-beforecopy"); tv.ShowLines = false; Assert.AreEqual (false, tv.ShowLines, "ShowLines-beforecopy"); tv.SkipLinkText = "Skip Navigation Links."; Assert.AreEqual ("Skip Navigation Links.", tv.SkipLinkText, "SkipLinkText-beforecopy"); tv.Target = string.Empty; Assert.AreEqual (string.Empty, tv.Target, "Target-beforecopy"); tv.Visible = true; Assert.AreEqual (true, tv.Visible, "Visible-beforecopy"); object state = tv.SaveState (); PokerTreeView copy = new PokerTreeView (); copy.LoadState (state); Assert.AreEqual (true, copy.AutoGenerateDataBindings, "AutoGenerateDataBindings-aftercopy"); Assert.AreEqual ("Collapse {0}", copy.CollapseImageToolTip, "CollapseImageToolTip-aftercopy"); Assert.AreEqual (string.Empty, copy.CollapseImageUrl, "CollapseImageUrl-aftercopy"); Assert.AreEqual (true, copy.EnableClientScript, "EnableClientScript-aftercopy"); Assert.AreEqual (-1, copy.ExpandDepth, "ExpandDepth-aftercopy"); Assert.AreEqual ("Expand {0}", copy.ExpandImageToolTip, "ExpandImageToolTip-aftercopy"); Assert.AreEqual (string.Empty, copy.ExpandImageUrl, "ExpandImageUrl-aftercopy"); Assert.AreEqual (TreeViewImageSet.Custom, copy.ImageSet, "ImageSet-aftercopy"); Assert.AreEqual (1, copy.LevelStyles.Count, "LevelStyles-aftercopy"); Assert.AreEqual (string.Empty, copy.LineImagesFolder, "LineImagesFolder-aftercopy"); Assert.AreEqual (-1, copy.MaxDataBindDepth, "MaxDataBindDepth-aftercopy"); Assert.AreEqual (20, copy.NodeIndent, "NodeIndent-aftercopy"); Assert.AreEqual (2, copy.Nodes.Count, "Nodes-aftercopy"); Assert.AreEqual (false, copy.NodeWrap, "NodeWrap-aftercopy"); Assert.AreEqual (string.Empty, copy.NoExpandImageUrl, "NoExpandImageUrl-aftercopy"); Assert.AreEqual (true, copy.PopulateNodesFromClient, "PopulateNodesFromClient-aftercopy"); Assert.AreEqual (TreeNodeTypes.None, copy.ShowCheckBoxes, "ShowCheckBoxes-aftercopy"); Assert.AreEqual (true, copy.ShowExpandCollapse, "ShowExpandCollapse-aftercopy"); Assert.AreEqual (false, copy.ShowLines, "ShowLines-aftercopy"); Assert.AreEqual ("Skip Navigation Links.", copy.SkipLinkText, "SkipLinkText-aftercopy"); Assert.AreEqual (string.Empty, copy.Target, "Target-aftercopy"); Assert.AreEqual (true, copy.Visible, "Visible-aftercopy"); }