コード例 #1
0
 public void ToolStripDropDownItem_DropDownItems_Get_ReturnsExpected()
 {
     using var item = new SubToolStripDropDownItem();
     Assert.Empty(item.DropDownItems);
     Assert.Same(item.DropDownItems, item.DropDownItems);
     Assert.True(item.HasDropDown);
 }
コード例 #2
0
        public void ToolStripDropDownItem_Ctor_String_Image_EventHandler_String_InvokeClick_CallsOnClick()
        {
            int          callCount = 0;
            EventHandler onClick   = (sender, e) => callCount++;

            using var item = new SubToolStripDropDownItem("text", null, onClick, "name");
            item.PerformClick();
            Assert.Equal(1, callCount);
        }
コード例 #3
0
 public void ToolStripDropDownItem_DropDown_Get_ReturnsExpected()
 {
     using var item = new SubToolStripDropDownItem();
     Assert.NotNull(item.DropDown);
     Assert.Same(item.DropDown, item.DropDown);
     Assert.True(item.DropDown.IsAutoGenerated);
     Assert.True(item.DropDown.ShowItemToolTips);
     Assert.Same(item, item.DropDown.OwnerItem);
     Assert.True(item.HasDropDown);
 }
コード例 #4
0
 public void ToolStripDropDownItem_DropDown_GetWithParent_ReturnsExpected(bool showItemToolTips)
 {
     using var parent = new ToolStrip
           {
               ShowItemToolTips = showItemToolTips
           };
     using var item = new SubToolStripDropDownItem
           {
               Parent = parent
           };
     Assert.NotNull(item.DropDown);
     Assert.Same(item.DropDown, item.DropDown);
     Assert.True(item.DropDown.IsAutoGenerated);
     Assert.Equal(showItemToolTips, item.DropDown.ShowItemToolTips);
     Assert.Same(item, item.DropDown.OwnerItem);
     Assert.True(item.HasDropDown);
 }
コード例 #5
0
 public void ToolStripDropDownItem_Ctor_String_Image_ToolStripItemArray(string text, Image image, ToolStripItem[] dropDownItems, ToolStripItem[] expectedDropDownItems)
 {
     using var item = new SubToolStripDropDownItem(text, image, dropDownItems);
     Assert.Equal(dropDownItems != null, item.HasDropDown);
     Assert.NotNull(item.AccessibilityObject);
     Assert.Null(item.AccessibleDefaultActionDescription);
     Assert.Null(item.AccessibleDescription);
     Assert.Null(item.AccessibleName);
     Assert.Equal(AccessibleRole.Default, item.AccessibleRole);
     Assert.Equal(ToolStripItemAlignment.Left, item.Alignment);
     Assert.False(item.AllowDrop);
     Assert.Equal(AnchorStyles.Top | AnchorStyles.Left, item.Anchor);
     Assert.True(item.AutoSize);
     Assert.False(item.AutoToolTip);
     Assert.True(item.Available);
     Assert.Null(item.BackgroundImage);
     Assert.Equal(ImageLayout.Tile, item.BackgroundImageLayout);
     Assert.Equal(new Rectangle(0, 0, 23, 23), item.Bounds);
     Assert.True(item.CanSelect);
     Assert.True(item.CanRaiseEvents);
     Assert.Null(item.Container);
     Assert.Equal(new Rectangle(2, 2, 19, 19), item.ContentRectangle);
     Assert.False(item.DefaultAutoToolTip);
     Assert.Equal(ToolStripItemDisplayStyle.ImageAndText, item.DefaultDisplayStyle);
     Assert.Equal(new Padding(0, 1, 0, 2), item.DefaultMargin);
     Assert.Equal(Padding.Empty, item.DefaultPadding);
     Assert.Equal(new Size(23, 23), item.DefaultSize);
     Assert.False(item.DesignMode);
     Assert.True(item.DismissWhenClicked);
     Assert.Equal(ToolStripItemDisplayStyle.ImageAndText, item.DisplayStyle);
     Assert.Equal(DockStyle.None, item.Dock);
     Assert.False(item.DoubleClickEnabled);
     Assert.NotNull(item.DropDown);
     Assert.Same(item.DropDown, item.DropDown);
     Assert.True(item.DropDown.IsAutoGenerated);
     Assert.True(item.DropDown.ShowItemToolTips);
     Assert.Same(item, item.DropDown.OwnerItem);
     Assert.Equal(ToolStripDropDownDirection.Default, item.DropDownDirection);
     Assert.Equal(expectedDropDownItems, item.DropDownItems.Cast <ToolStripItem>());
     Assert.Same(item.DropDownItems, item.DropDownItems);
     Assert.True(item.HasDropDown);
     Assert.Equal(Point.Empty, item.DropDownLocation);
     Assert.True(item.Enabled);
     Assert.NotNull(item.Events);
     Assert.Same(item.Events, item.Events);
     Assert.NotNull(item.Font);
     Assert.NotSame(Control.DefaultFont, item.Font);
     Assert.Same(item.Font, item.Font);
     Assert.Equal(Control.DefaultForeColor, item.ForeColor);
     Assert.Equal(expectedDropDownItems.Length > 0, item.HasDropDownItems);
     Assert.True(item.HasDropDown);
     Assert.Equal(23, item.Height);
     Assert.Equal(image, item.Image);
     Assert.Equal(ContentAlignment.MiddleCenter, item.ImageAlign);
     Assert.Equal(-1, item.ImageIndex);
     Assert.Empty(item.ImageKey);
     Assert.Equal(ToolStripItemImageScaling.SizeToFit, item.ImageScaling);
     Assert.Equal(Color.Empty, item.ImageTransparentColor);
     Assert.False(item.IsDisposed);
     Assert.False(item.IsOnDropDown);
     Assert.False(item.IsOnOverflow);
     Assert.Equal(new Padding(0, 1, 0, 2), item.Margin);
     Assert.Equal(MergeAction.Append, item.MergeAction);
     Assert.Equal(-1, item.MergeIndex);
     Assert.Empty(item.Name);
     Assert.Equal(ToolStripItemOverflow.AsNeeded, item.Overflow);
     Assert.Null(item.OwnerItem);
     Assert.Equal(Padding.Empty, item.Padding);
     Assert.Null(item.Parent);
     Assert.Equal(ToolStripItemPlacement.None, item.Placement);
     Assert.False(item.Pressed);
     Assert.Equal(RightToLeft.Inherit, item.RightToLeft);
     Assert.False(item.RightToLeftAutoMirrorImage);
     Assert.False(item.Selected);
     Assert.Equal(SystemInformation.MenuAccessKeysUnderlined, item.ShowKeyboardCues);
     Assert.Null(item.Site);
     Assert.Equal(new Size(23, 23), item.Size);
     Assert.Null(item.Tag);
     Assert.Equal(text, item.Text);
     Assert.Equal(ContentAlignment.MiddleCenter, item.TextAlign);
     Assert.Equal(ToolStripTextDirection.Horizontal, item.TextDirection);
     Assert.Equal(TextImageRelation.ImageBeforeText, item.TextImageRelation);
     Assert.Null(item.ToolTipText);
     Assert.False(item.Visible);
     Assert.Equal(23, item.Width);
 }