public void Menu_ViewState() { PokerMenu b = new PokerMenu (); PokerMenu copy = new PokerMenu (); b.ToolTip = "mytest1"; b.Target = "mytest2"; b.BackColor = Color.Red; b.BorderColor = Color.Red; b.BorderStyle = BorderStyle.Dotted; b.BorderWidth = 1; b.ForeColor = Color.Red; b.Height = 100; b.MaximumDynamicDisplayLevels = 2; b.Orientation = Orientation.Vertical; b.PathSeparator = '-'; b.ScrollDownImageUrl = "test"; b.ScrollDownText = "test"; b.ScrollUpImageUrl = "test"; b.ScrollUpText = "test"; b.SkipLinkText = "test"; b.Visible = false; b.Width = 100; b.TabIndex = 1; object state = b.DoSaveViewState (); copy.DoLoadViewState (state); Assert.AreEqual ("mytest1", copy.ToolTip, "ViewState#1"); Assert.AreEqual ("mytest2", copy.Target, "ViewState#2"); Assert.AreEqual (Color.Red, copy.BackColor, "ViewState#3"); Assert.AreEqual (Color.Red, copy.BorderColor , "ViewState#4"); Assert.AreEqual (BorderStyle.Dotted, copy.BorderStyle, "ViewState#5"); Assert.AreEqual (Unit.Pixel(1), copy.BorderWidth, "ViewState#6"); Assert.AreEqual (Color.Red, copy.ForeColor, "ViewState#8"); Assert.AreEqual (Unit.Pixel(100), copy.Height, "ViewState#9"); Assert.AreEqual (2, copy.MaximumDynamicDisplayLevels, "ViewState#10"); Assert.AreEqual (Orientation.Vertical, copy.Orientation, "ViewState#11"); Assert.AreEqual ('-', copy.PathSeparator, "ViewState#12"); Assert.AreEqual ("test", copy.ScrollDownImageUrl, "ViewState#13"); Assert.AreEqual ("test", copy.ScrollDownText, "ViewState#14"); Assert.AreEqual ("test", copy.ScrollUpImageUrl, "ViewState#15"); Assert.AreEqual ("test", copy.ScrollUpText, "ViewState#16"); Assert.AreEqual ("test", copy.SkipLinkText, "ViewState#17"); Assert.AreEqual (1, copy.TabIndex, "ViewState#18"); Assert.AreEqual (false, copy.Visible, "ViewState#19"); Assert.AreEqual (Unit.Pixel (100), copy.Width, "ViewState#20"); }
public void Menu_ViewStateNotWorking() { PokerMenu b = new PokerMenu (); PokerMenu copy = new PokerMenu (); b.Font.Size = 10; object state = b.DoSaveViewState (); copy.DoLoadViewState (state); Assert.AreEqual ("10pt", copy.Font.Size.ToString() , "ViewState#7"); }
public static void _EndTagRender (Page p) { PokerMenu pm = new PokerMenu (); #if NET_4_0 pm.RenderingCompatibility = new Version (2, 0); #endif p.Form.Controls.Add (pm); StringWriter sw = new StringWriter (); HtmlTextWriter tw = new HtmlTextWriter (sw); pm.RenderBeginTag (tw); pm.RenderEndTag (tw); string RenderedControlHtml = sw.ToString (); #if NET_4_0 string OriginControlHtml = "<a href=\"#ctl01_SkipLink\"><img alt=\"Skip Navigation Links\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><table id=\"ctl01\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\r\n</table><a id=\"ctl01_SkipLink\"></a>"; #else string OriginControlHtml = "<a href=\"#ctl01_SkipLink\"><img alt=\"Skip Navigation Links\" src=\"/NunitWeb/WebResource.axd?d=4RHYfeNnynkXiM59uthjZg2&t=633802729995006876\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><table id=\"ctl01\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\r\n</table><a id=\"ctl01_SkipLink\"></a>"; #endif HtmlDiff.AssertAreEqual(OriginControlHtml, RenderedControlHtml,"RenderEndTag"); }
public static void _EndTagRender_List (Page p) { PokerMenu pm = new PokerMenu (); pm.RenderingCompatibility = new Version (4, 0); pm.RenderingMode = MenuRenderingMode.List; p.Form.Controls.Add (pm); StringWriter sw = new StringWriter (); HtmlTextWriter tw = new HtmlTextWriter (sw); pm.RenderBeginTag (tw); pm.RenderEndTag (tw); string RenderedControlHtml = sw.ToString (); string OriginControlHtml = "<a href=\"#ctl01_SkipLink\"><img alt=\"Skip Navigation Links\" src=\"/NunitWeb/WebResource.axd?d=8VpphgAbakKUC_J8R6hR0Q2&t=634067491135766272\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"ctl01\">\r\n\r\n</div><a id=\"ctl01_SkipLink\"></a>"; HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "RenderEndTag"); }
public void Menu_ControlState() { PokerMenu p = new PokerMenu (); MenuItem I1 = new MenuItem (); MenuItem I2 = new MenuItem (); p.Items.Add (I1); p.Items.Add (I2); MenuEventArgs e = new MenuEventArgs (I1); p.DoOnMenuItemClick (e); object state = p.DoSaveControlState (); p.DoLoadControlState (state); e = new MenuEventArgs (I2); p.DoOnMenuItemClick (e); Console.WriteLine(); }
public void Menu_FindItem () { PokerMenu p = new PokerMenu (); MenuItem I = new MenuItem (); string path = I.ValuePath; p.Items.Add (I); MenuItem V = new MenuItem (); I.ChildItems.Add (V); MenuItem copy = p.FindItem (path); Assert.AreEqual (I, copy, "FindItem#1"); path = V.ValuePath; Assert.AreEqual (V, p.FindItem (path), "FindItem#2"); }
public void Menu_ChangeDefaultProperties () { PokerMenu p = new PokerMenu (); Button B = new Button (); p.Controls.Add (B); Assert.AreEqual (1,p.Controls.Count, "ControlsCollection"); MenuItemBinding M = new MenuItemBinding (); M.DataMember = "test"; M.Depth = 0; M.TextField = "title"; M.NavigateUrl="url"; Object C = p.DataBindings; Assert.AreEqual (0, p.DataBindings.Count, "DataBindings#1"); ((MenuItemBindingCollection)C).Add (M); Assert.AreEqual (1,p.DataBindings.Count,"DataBindings#2"); p.DisappearAfter = 100; Assert.AreEqual (100, p.DisappearAfter, "DisappearAfter"); p.DynamicBottomSeparatorImageUrl = "test.aspx"; Assert.AreEqual ("test.aspx", p.DynamicBottomSeparatorImageUrl, "DynamicBottomSeparatorImageUrl"); p.DynamicEnableDefaultPopOutImage = false; Assert.AreEqual (false,p.DynamicEnableDefaultPopOutImage, "DynamicEnableDefaultPopOutImage"); p.DynamicHorizontalOffset = 10; Assert.AreEqual (10, p.DynamicHorizontalOffset, "DynamicHorizontalOffset"); p.DynamicHoverStyle.BackColor = Color.Red; Assert.AreEqual (Color.Red ,p.DynamicHoverStyle.BackColor, "DynamicHoverStyle"); p.DynamicItemFormatString = "Mytest"; Assert.AreEqual ("Mytest", p.DynamicItemFormatString, "DynamicItemFormatString"); MyWebControl.Image myImage = new MyWebControl.Image (); myImage.ImageUrl = "myimage.jpg"; ImageTemplate Template = new ImageTemplate (); Template.MyImage = myImage; // end create template image p.DynamicItemTemplate = Template; Assert.IsNotNull (p.DynamicItemTemplate, "RootNodeTemplate"); Assert.AreEqual (typeof (ImageTemplate), p.DynamicItemTemplate.GetType (), "RootNodeTemplate#1"); p.DynamicMenuItemStyle.BackColor = Color.Red; Assert.AreEqual (Color.Red, p.DynamicMenuItemStyle.BackColor, "DynamicMenuItemStyle"); p.DynamicMenuStyle.BackColor = Color.Red; Assert.AreEqual (Color.Red,p.DynamicMenuStyle.BackColor, "DynamicMenuStyle"); p.DynamicPopOutImageUrl = "test"; Assert.AreEqual ("test", p.DynamicPopOutImageUrl, "DynamicPopOutImageUrl"); p.DynamicSelectedStyle.BackColor = Color.Red; Assert.AreEqual (Color.Red,p.DynamicSelectedStyle.BackColor, "DynamicSelectedStyle"); p.DynamicTopSeparatorImageUrl = "test"; Assert.AreEqual ("test", p.DynamicTopSeparatorImageUrl, "DynamicTopSeparatorImageUrl"); p.DynamicVerticalOffset = 10; Assert.AreEqual (10, p.DynamicVerticalOffset, "DynamicVerticalOffset"); MenuItem I = new MenuItem (); I.NavigateUrl = "default.aspx"; I.Text = "MyText"; I.ToolTip = "Test"; p.Items.Add (I); Assert.AreEqual (1, p.Items.Count, "Items"); p.ItemWrap = true; Assert.AreEqual (true, p.ItemWrap, "ItemWrap"); MenuItemStyle S = new MenuItemStyle (); S.BackColor = Color.Red; p.LevelSelectedStyles.Add (S); Assert.AreEqual (1,p.LevelSelectedStyles.Count , "LevelSelectedStyles#1"); Assert.AreEqual (true, p.LevelSelectedStyles.Contains (S), "LevelSelectedStyles#2"); SubMenuStyle SM = new SubMenuStyle (); SM.BackColor = Color.Red; p.LevelSubMenuStyles.Add (SM); Assert.AreEqual(1, p.LevelSubMenuStyles.Count, "LevelSubMenuStyles#1"); Assert.AreEqual (true, p.LevelSubMenuStyles.Contains (SM), "LevelSubMenuStyles#2"); p.MaximumDynamicDisplayLevels = 5; Assert.AreEqual (5, p.MaximumDynamicDisplayLevels, "MaximumDynamicDisplayLevels"); p.Orientation = Orientation.Horizontal; Assert.AreEqual (Orientation.Horizontal, p.Orientation, "Orientation"); p.PathSeparator = 'A'; Assert.AreEqual ('A', p.PathSeparator, "PathSeparator"); p.ScrollDownImageUrl = "test"; Assert.AreEqual ("test", p.ScrollDownImageUrl, "ScrollDownImageUrl"); p.ScrollDownText = "test"; Assert.AreEqual ("test", p.ScrollDownText, "ScrollDownText"); // This properties will be checked in events part of tests // Assert.AreEqual (0, p.SelectedItem, "p.SelectedItem"); // Assert.AreEqual (string.Empty, p.SelectedValue, "SelectedValue"); p.SkipLinkText = "test"; Assert.AreEqual ("test", p.SkipLinkText, "SkipLinkText"); p.StaticBottomSeparatorImageUrl = "test"; Assert.AreEqual ("test", p.StaticBottomSeparatorImageUrl, "StaticBottomSeparatorImageUrl"); p.StaticDisplayLevels = 2; Assert.AreEqual (2, p.StaticDisplayLevels, "StaticDisplayLevels"); p.StaticEnableDefaultPopOutImage = false; Assert.AreEqual (false, p.StaticEnableDefaultPopOutImage, "StaticEnableDefaultPopOutImage"); p.StaticHoverStyle.BackColor = Color.Red; Assert.AreEqual(Color.Red, p.StaticHoverStyle.BackColor, "StaticHoverStyle"); p.StaticItemFormatString = "test"; Assert.AreEqual ("test", p.StaticItemFormatString, "StaticItemFormatString"); p.StaticItemTemplate = Template; Assert.IsNotNull (p.StaticItemTemplate, "StaticItemTemplate"); p.StaticMenuItemStyle.BackColor = Color.Red; Assert.AreEqual(Color.Red,p.StaticMenuItemStyle.BackColor, "StaticMenuItemStyle"); p.StaticMenuStyle.BackColor = Color.Red; Assert.AreEqual (Color.Red,p.StaticMenuStyle.BackColor, "StaticMenuStyle"); p.StaticPopOutImageUrl = "test"; Assert.AreEqual ("test", p.StaticPopOutImageUrl, "StaticPopOutImageUrl"); p.StaticSelectedStyle.BackColor = Color.Red; Assert.AreEqual(Color.Red,p.StaticSelectedStyle.BackColor, "StaticSelectedStyle"); p.StaticSubMenuIndent = 20; Assert.AreEqual (Unit.Pixel (20), p.StaticSubMenuIndent, "StaticSubMenuIndent"); p.StaticTopSeparatorImageUrl = "test"; Assert.AreEqual ("test", p.StaticTopSeparatorImageUrl, "StaticTopSeparatorImageUrl"); p.Target = "test"; Assert.AreEqual ("test", p.Target, "Target"); }
public void Menu_DefaultProperties () { PokerMenu p = new PokerMenu (); Assert.AreEqual ("Click",PokerMenu.MenuItemClickCommandName,"Staic_MenuItemClickCommandName"); Assert.AreEqual (0,p.Controls.Count,"ControlsCollection"); Assert.AreEqual (0,p.DataBindings.Count,"DataBindings"); Assert.AreEqual (500,p.DisappearAfter,"DisappearAfter"); Assert.AreEqual (string.Empty, p.DynamicBottomSeparatorImageUrl, "DynamicBottomSeparatorImageUrl"); Assert.IsTrue (p.DynamicEnableDefaultPopOutImage, "DynamicEnableDefaultPopOutImage"); Assert.AreEqual (0, p.DynamicHorizontalOffset, "DynamicHorizontalOffset"); Assert.IsNotNull (p.DynamicHoverStyle, "DynamicHoverStyle"); Assert.AreEqual ("", p.DynamicItemFormatString, "DynamicItemFormatString"); Assert.IsNull (p.DynamicItemTemplate, "DynamicItemTemplate"); Assert.IsNotNull (p.DynamicMenuItemStyle, "DynamicMenuItemStyle"); Assert.IsNotNull (p.DynamicMenuStyle, "DynamicMenuStyle"); Assert.AreEqual (string.Empty,p.DynamicPopOutImageUrl,"DynamicPopOutImageUrl"); Assert.IsNotNull (p.DynamicSelectedStyle, "DynamicSelectedStyle"); Assert.AreEqual (string.Empty, p.DynamicTopSeparatorImageUrl, "DynamicTopSeparatorImageUrl"); Assert.AreEqual (0, p.DynamicVerticalOffset, "DynamicVerticalOffset"); Assert.AreEqual (0, p.Items.Count, "Items"); Assert.AreEqual (false, p.ItemWrap, "ItemWrap"); Assert.IsNotNull (p.LevelSelectedStyles, "LevelSelectedStyles"); Assert.IsNotNull (p.LevelSubMenuStyles, "LevelSubMenuStyles"); Assert.AreEqual (3, p.MaximumDynamicDisplayLevels, "MaximumDynamicDisplayLevels"); Assert.AreEqual (Orientation.Vertical, p.Orientation, "Orientation"); Assert.AreEqual ("/", p.PathSeparator.ToString(), "PathSeparator"); Assert.AreEqual (string.Empty, p.ScrollDownImageUrl, "ScrollDownImageUrl"); Assert.AreEqual (null, p.SelectedItem, "p.SelectedItem"); Assert.AreEqual (string.Empty, p.StaticBottomSeparatorImageUrl, "StaticBottomSeparatorImageUrl"); Assert.AreEqual (1, p.StaticDisplayLevels, "StaticDisplayLevels"); Assert.AreEqual (true, p.StaticEnableDefaultPopOutImage, "StaticEnableDefaultPopOutImage"); Assert.IsNotNull (p.StaticHoverStyle, "StaticHoverStyle"); Assert.AreEqual ("", p.StaticItemFormatString, "StaticItemFormatString"); Assert.AreEqual (null, p.StaticItemTemplate, "StaticItemTemplate"); Assert.IsNotNull (p.StaticMenuItemStyle, "StaticMenuItemStyle"); Assert.IsNotNull (p.StaticMenuStyle, "StaticMenuStyle"); Assert.AreEqual ("", p.StaticPopOutImageUrl, "StaticPopOutImageUrl"); Assert.IsNotNull (p.StaticSelectedStyle, "StaticSelectedStyle"); #if NET_4_0 Assert.IsTrue (p.StaticSubMenuIndent.IsEmpty, "StaticSubMenuIndent"); #else Assert.AreEqual (Unit.Pixel(16), p.StaticSubMenuIndent, "StaticSubMenuIndent"); #endif Assert.AreEqual ("", p.StaticTopSeparatorImageUrl, "StaticTopSeparatorImageUrl"); Assert.AreEqual ("", p.Target, "Target"); Assert.IsNotNull (p.OnTagKey (), "TagKey"); }
public void Menu_DefaultProperties_2 () { PokerMenu p = new PokerMenu (); Assert.AreEqual ("Skip Navigation Links", p.SkipLinkText, "SkipLinkText"); Assert.AreEqual (string.Empty, p.SelectedValue, "SelectedValue"); Assert.AreEqual ("Scroll up", p.ScrollUpText, "ScrollUpText"); Assert.AreEqual ("Expand {0}", p.StaticPopOutImageTextFormatString, "StaticPopOutImageTextFormatString"); //not implemented Assert.AreEqual ("Scroll down", p.ScrollDownText, "ScrollDownText"); Assert.AreEqual ("Expand {0}", p.DynamicPopOutImageTextFormatString, "DynamicPopOutImageTextFormatString"); //not implemented }
public void Menu_RenderingMode () { var m = new PokerMenu (); Assert.AreEqual (MenuRenderingMode.Default, m.RenderingMode, "#A1"); Array values = Enum.GetValues (typeof (MenuRenderingMode)); int minValue = Int32.MaxValue, maxValue = Int32.MinValue; foreach (object v in values) { int value = (int) v; if (value < minValue) minValue = value; else if (value > maxValue) maxValue = value; } AssertExtensions.Throws<ArgumentOutOfRangeException> (() => { m.RenderingMode = (MenuRenderingMode) (minValue - 1); }, "#A2-1"); AssertExtensions.Throws<ArgumentOutOfRangeException> (() => { m.RenderingMode = (MenuRenderingMode) (maxValue + 1); }, "#A2-2"); }
public void PreRenderEvent (Page p) { PokerMenu pm = new PokerMenu (); p.Controls.Add (pm); pm.PreRender += new EventHandler (OnPreRenderHandler); Assert.AreEqual (false, OnPreRender, "BeforePreRender"); pm.DoOnPreRender (new EventArgs ()); Assert.AreEqual (true, OnPreRender, "AfterPreRender"); }
public void Menu_BubbleEvent () { PokerMenu pm = new PokerMenu (); MenuItem item = new MenuItem ("Root"); pm.Items.Add (item); pm.MenuItemClick += new MenuEventHandler (pm_MenuItemClick); _MenuItemClick = false; MenuEventArgs clickCommandArg = new MenuEventArgs (item, null, new CommandEventArgs (Menu.MenuItemClickCommandName, null)); CommandEventArgs notClickCommandArg = new CommandEventArgs (Menu.MenuItemClickCommandName + "No", null); Assert.AreEqual (true, pm.DoOnBubbleEvent (notClickCommandArg), "Bubble Event#1"); Assert.AreEqual (false, _MenuItemClick, "MenuItemClick Bubbled"); Assert.AreEqual (true, pm.DoOnBubbleEvent (clickCommandArg), "Bubble Event#2"); Assert.AreEqual (true, _MenuItemClick, "MenuItemClick Bubbled"); Assert.AreEqual (false, pm.DoOnBubbleEvent (new EventArgs ()), "Bubble Event#3"); }
public void Menu_Events () { Page myPage = new Page (); PokerMenu p = new PokerMenu (); MenuItem I = new MenuItem (); p.Items.Add (I); myPage.Controls.Add(p); p.Init += new EventHandler(OnInitHandler); p.DataBinding += new EventHandler (OnDataBindingHandler); p.DataBound += new EventHandler(OnDataDataBoundHandler); p.MenuItemClick += new MenuEventHandler(OnMenuItemClickHandler); p.MenuItemDataBound += new MenuEventHandler (OnMenuItemDataBoundHandler); Assert.AreEqual (false, OnDataBinding, "BeforeOnDataBinding"); p.DoOnDataBind (new EventArgs ()); Assert.AreEqual (true, OnDataBinding, "AfterOnDataBinding"); Assert.AreEqual (false, OnDataBound, "BeforeOnDataBound"); p.DoOnDataBound (new EventArgs ()); Assert.AreEqual (true, OnDataBound, "AfterOnDataBinding"); MenuEventArgs e = new MenuEventArgs (I); Assert.AreEqual (false, OnMenuItemClick, "BeforeMenuItemClick"); p.DoOnMenuItemClick (e); Assert.AreEqual (true, OnMenuItemClick, "AfterMenuItemClick"); Assert.AreEqual (false, OnInit, "BeforeOnInit"); p.DoOnInit (new EventArgs()); Assert.AreEqual (true, OnInit, "AfterOnInit"); Assert.AreEqual (false, OnMenuItemDataBound, "BeforeMenuItemDataBound"); p.DoMenuItemDataBound(e); Assert.AreEqual (true, OnMenuItemDataBound, "AfterMenuItemDataBound"); }
public void Menu_ViewStateItems () { PokerMenu b = new PokerMenu (); MenuItem R = new MenuItem ("root", "value-root"); MenuItem N1 = new MenuItem ("node1", "value-node1"); MenuItem N2 = new MenuItem ("node2", "value-node2"); R.ChildItems.Add (N1); R.ChildItems.Add (N2); b.Items.Add (R); PokerMenu copy = new PokerMenu (); object state = b.DoSaveViewState (); copy.DoLoadViewState (state); Assert.AreEqual (1, copy.Items.Count, "ViewStateItems#1"); Assert.AreEqual (2, copy.Items [0].ChildItems.Count, "ViewStateItems#2"); Assert.AreEqual (0, copy.Items [0].ChildItems [0].ChildItems.Count, "ViewStateItems#3"); Assert.AreEqual ("node1", copy.Items [0].ChildItems [0].Text, "ViewStateItems#4"); Assert.AreEqual ("value-node1", copy.Items [0].ChildItems [0].Value, "ViewStateItems#5"); Assert.AreEqual (false, copy.Items [0].ChildItems [0].DataBound, "ViewStateItems#6"); Assert.AreEqual ("", copy.Items [0].ChildItems [0].DataPath, "ViewStateItems#7"); }
public void Menu_ChangeDefaultProperties_2 () { PokerMenu p = new PokerMenu (); p.ScrollUpText = "test"; Assert.AreEqual ("test", p.ScrollUpText, "ScrollUpText"); p.DynamicPopOutImageTextFormatString = "test"; Assert.AreEqual ("test", p.DynamicPopOutImageTextFormatString, "DynamicPopOutImageTextFormatString"); p.StaticPopOutImageTextFormatString = "test"; Assert.AreEqual ("test", p.StaticPopOutImageTextFormatString, "StaticPopOutImageTextFormatString"); }
public void Menu_ViewStateDataBoundItems () { PokerMenu b = new PokerMenu (); SetDataBindings (b); b.DataSource = CreateXmlDataSource (); b.DataBind (); PokerMenu copy = new PokerMenu (); object state = b.DoSaveViewState (); copy.DoLoadViewState (state); CheckMenuItems (copy); }
public static void _EndTagRender (Page p) { PokerMenu pm = new PokerMenu (); p.Form.Controls.Add (pm); StringWriter sw = new StringWriter (); HtmlTextWriter tw = new HtmlTextWriter (sw); pm.RenderBeginTag (tw); pm.RenderEndTag (tw); string RenderedControlHtml = sw.ToString (); string OriginControlHtml = @"<a href=""#ctl01_SkipLink""> <img alt=""Skip Navigation Links"" src=""/NunitWeb/WebResource.axd?d=gZrz8lvSQfolS1pG07HX9g2&t=632784640484505569"" width=""0"" style=""border-width:0px"" height=""0"" style=""border-width:0px;"" /> </a><table id=""ctl01"" cellpadding=""0"" cellspacing=""0"" border=""0""> </table><a id=""ctl01_SkipLink""></a>"; HtmlDiff.AssertAreEqual(OriginControlHtml, RenderedControlHtml,"RenderEndTag"); }