//
// Tests for System.Web.UI.WebControls.ImageMap.cs
//
// Author:
// Hagit Yidov (hagity@mainsoft.com
//
// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.IO;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoTests.stand_alone.WebHarness;
using MonoTests.SystemWeb.Framework;
using System.Threading;
namespace MonoTests.System.Web.UI.WebControls {
class PokerTreeNode : TreeNode {
// View state Stuff
public PokerTreeNode () {
TrackViewState ();
}
public object SaveState () {
return SaveViewState ();
}
public void LoadState (object o) {
LoadViewState (o);
}
public bool IsTrackingViewStateBase { get { return (base.IsTrackingViewState); } }
public virtual object CloneBase () {
return (base.Clone ());
}
public virtual void RenderPostTextBase (HtmlTextWriter writer) {
base.RenderPostText (writer);
}
public virtual void RenderPreTextBase (HtmlTextWriter writer) {
base.RenderPreText (writer);
}
}
[TestFixture]
public class TreeNodeTest {
[Test]
public void TreeNode_DefaultProperties () {
PokerTreeNode tn = new PokerTreeNode ();
Assert.AreEqual (false, tn.Checked, "Checked");
Assert.AreEqual (0, tn.ChildNodes.Count, "ChildNodes.Count");
Assert.AreEqual (false, tn.DataBound, "DataBound");
Assert.AreEqual (null, tn.DataItem, "DataItem");
Assert.AreEqual (string.Empty, tn.DataPath, "DataPath");
Assert.AreEqual (0, tn.Depth, "Depth");
Assert.AreEqual (null, tn.Expanded, "Expanded");
Assert.AreEqual (string.Empty, tn.ImageToolTip, "ImageToolTip");
Assert.AreEqual (string.Empty, tn.ImageUrl, "ImageUrl");
Assert.AreEqual (string.Empty, tn.NavigateUrl, "NavigateUrl");
Assert.AreEqual (null, tn.Parent, "Parent");
Assert.AreEqual (false, tn.PopulateOnDemand, "PopulateOnDemand");
Assert.AreEqual (TreeNodeSelectAction.Select, tn.SelectAction, "SelectAction");
Assert.AreEqual (false, tn.Selected, "Selected");
Assert.AreEqual (null, tn.ShowCheckBox, "ShowCheckBox");
Assert.AreEqual (string.Empty, tn.Target, "Target");
Assert.AreEqual (string.Empty, tn.Text, "Text");
Assert.AreEqual (string.Empty, tn.Value, "Value");
Assert.AreEqual (string.Empty, tn.ToolTip, "ToolTip");
Assert.AreEqual (string.Empty, tn.ValuePath, "ValuePath");
Assert.AreEqual (true, tn.IsTrackingViewStateBase, "IsTrackingViewState");
}
[Test]
public void TreeNode_AssignToDefaultProperties ()
{
PokerTreeNode tn = new PokerTreeNode ();
tn.Checked = false;
Assert.AreEqual (false, tn.Checked, "Checked");
tn.ChildNodes.Add (new TreeNode ());
Assert.AreEqual (1, tn.ChildNodes.Count, "ChildNodes.Count");
tn.Expanded = false;
Assert.AreEqual (false, tn.Expanded, "Expanded");
tn.ImageToolTip = string.Empty;
Assert.AreEqual (string.Empty, tn.ImageToolTip, "ImageToolTip");
tn.ImageUrl = string.Empty;
Assert.AreEqual (string.Empty, tn.ImageUrl, "ImageUrl");
tn.NavigateUrl = string.Empty;
Assert.AreEqual (string.Empty, tn.NavigateUrl, "NavigateUrl");
tn.PopulateOnDemand = false;
Assert.AreEqual (false, tn.PopulateOnDemand, "PopulateOnDemand");
tn.SelectAction = TreeNodeSelectAction.Select;
Assert.AreEqual (TreeNodeSelectAction.Select, tn.SelectAction, "SelectAction");
tn.Selected = false;
Assert.AreEqual (false, tn.Selected, "Selected");
tn.ShowCheckBox = false;
Assert.AreEqual (false, tn.ShowCheckBox, "ShowCheckBox");
tn.Target = string.Empty;
Assert.AreEqual (string.Empty, tn.Target, "Target");
tn.Text = string.Empty;
Assert.AreEqual (string.Empty, tn.Text, "Text");
tn.Value = string.Empty;
Assert.AreEqual (string.Empty, tn.Value, "Value");
tn.ToolTip = string.Empty;
Assert.AreEqual (string.Empty, tn.ToolTip, "ToolTip");
}
[Test]
public void TreeNode_Method_Select () {
PokerTreeNode tn = new PokerTreeNode ();
Assert.AreEqual (false, tn.Selected, "BeforeSelect");
tn.Select ();
Assert.AreEqual (true, tn.Selected, "AfterSelect");
}
[Test]
public void TreeNode_Method_Clone () {
PokerTreeNode tn1 = new PokerTreeNode ();
TreeNode tn2 = new TreeNode ();
tn1.Text = "CloneThisNode";
tn1.Value = "111";
Assert.AreEqual (string.Empty, tn2.Text, "BeforeClone1");
Assert.AreEqual (string.Empty, tn2.Value, "BeforeClone2");
tn2 = (TreeNode) tn1.CloneBase ();
Assert.AreEqual ("CloneThisNode", tn2.Text, "AfterClone1");
Assert.AreEqual ("111", tn2.Value, "AfterClone2");
}
[Test]
[Category ("NunitWeb")]
public void TreeNode_NavigateUrl () {
WebTest t = new WebTest (PageInvoker.CreateOnLoad (pageLoadNavigateUrl));
string strTarget =
@"