Ejemplo n.º 1
0
        public void ScrollableControl_OnLayout_Invoke_CallsLayout(LayoutEventArgs eventArgs)
        {
            var control   = new SubScrollableControl();
            int callCount = 0;
            LayoutEventHandler handler = (sender, e) =>
            {
                Assert.Same(control, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };

            // Call with handler.
            control.Layout += handler;
            control.OnLayout(eventArgs);
            Assert.Equal(1, callCount);

            // Remove handler.
            control.Layout -= handler;
            control.OnLayout(eventArgs);
            Assert.Equal(1, callCount);
        }
Ejemplo n.º 2
0
        public void ScrollableControl_OnPaddingChanged_Invoke_CallsHandler()
        {
            var          control   = new SubScrollableControl();
            var          eventArgs = new EventArgs();
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(control, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };

            // Call with handler.
            control.PaddingChanged += handler;
            control.OnPaddingChanged(eventArgs);
            Assert.Equal(1, callCount);

            // Remove handler.
            control.PaddingChanged -= handler;
            control.OnPaddingChanged(eventArgs);
            Assert.Equal(1, callCount);
        }
Ejemplo n.º 3
0
        public void ScrollableControl_OnScroll_Invoke_CallsHandler()
        {
            var control   = new SubScrollableControl();
            var eventArgs = new ScrollEventArgs(ScrollEventType.First, 0);
            int callCount = 0;
            ScrollEventHandler handler = (sender, e) =>
            {
                Assert.Same(control, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };

            // Call with handler.
            control.Scroll += handler;
            control.OnScroll(eventArgs);
            Assert.Equal(1, callCount);

            // Remove handler.
            control.Scroll -= handler;
            control.OnScroll(eventArgs);
            Assert.Equal(1, callCount);
        }
Ejemplo n.º 4
0
        public void ScrollableControl_OnPaddingChanged_Invoke_Success()
        {
            var control = new SubScrollableControl();

            // No handler.
            control.OnPaddingChangedEntry(null);

            // Handler.
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Equal(control, sender);
                callCount++;
            };

            control.PaddingChanged += handler;
            control.OnPaddingChangedEntry(null);
            Assert.Equal(1, callCount);

            // Should not call if the handler is removed.
            control.PaddingChanged -= handler;
            control.OnPaddingChangedEntry(null);
            Assert.Equal(1, callCount);
        }
Ejemplo n.º 5
0
        public void SetDisplayRectLocation_InvokeWithoutHandle_Success(bool autoScroll, int x, int y, Rectangle expectedDisplayRectangle, Rectangle expectedBounds)
        {
            var control = new SubScrollableControl
            {
                AutoScroll = autoScroll,
                ClientSize = new Size(70, 80)
            };

            // Without child.
            control.SetDisplayRectLocation(x, y);
            Assert.Equal(new Rectangle(0, 0, 70, 80), control.DisplayRectangle);
            Assert.Equal(Point.Empty, control.AutoScrollPosition);

            // With child.
            var child = new LargeControl();

            control.Controls.Add(child);
            Assert.Equal(new Rectangle(0, 0, 100, 150), child.Bounds);

            control.SetDisplayRectLocation(x, y);
            Assert.Equal(expectedDisplayRectangle, control.DisplayRectangle);
            Assert.Equal(expectedDisplayRectangle.Location, control.AutoScrollPosition);
            Assert.Equal(expectedBounds, child.Bounds);
        }
Ejemplo n.º 6
0
 public void ScrollableControl_AdjustFormScrollbars_Invoke_Success(SubScrollableControl control, bool displayScrollbars, bool expectedHScroll, bool expectedVScroll)
 {
     control.AdjustFormScrollbars(displayScrollbars);
     Assert.Equal(expectedHScroll, control.HScroll);
     Assert.Equal(expectedVScroll, control.VScroll);
 }
Ejemplo n.º 7
0
        public void ScrollableControl_Ctor_Default()
        {
            using var control = new SubScrollableControl();
            Assert.False(control.AllowDrop);
            Assert.Equal(AnchorStyles.Top | AnchorStyles.Left, control.Anchor);
            Assert.False(control.AutoScroll);
            Assert.Equal(Size.Empty, control.AutoScrollMargin);
            Assert.Equal(Size.Empty, control.AutoScrollMinSize);
            Assert.Equal(Point.Empty, control.AutoScrollPosition);
            Assert.False(control.AutoSize);
            Assert.Equal(Control.DefaultBackColor, control.BackColor);
            Assert.Null(control.BackgroundImage);
            Assert.Equal(ImageLayout.Tile, control.BackgroundImageLayout);
            Assert.Null(control.BindingContext);
            Assert.Equal(0, control.Bottom);
            Assert.Equal(Rectangle.Empty, control.Bounds);
            Assert.True(control.CanEnableIme);
            Assert.True(control.CanRaiseEvents);
            Assert.True(control.CausesValidation);
            Assert.Equal(Rectangle.Empty, control.ClientRectangle);
            Assert.Equal(Size.Empty, control.ClientSize);
            Assert.Null(control.Container);
            Assert.Null(control.ContextMenu);
            Assert.Null(control.ContextMenuStrip);
            Assert.Empty(control.Controls);
            Assert.Same(control.Controls, control.Controls);
            Assert.False(control.Created);
            Assert.Same(Cursors.Default, control.Cursor);
            Assert.Same(Cursors.Default, control.DefaultCursor);
            Assert.Equal(ImeMode.Inherit, control.DefaultImeMode);
            Assert.Equal(new Padding(3), control.DefaultMargin);
            Assert.Equal(Size.Empty, control.DefaultMaximumSize);
            Assert.Equal(Size.Empty, control.DefaultMinimumSize);
            Assert.Equal(Padding.Empty, control.DefaultPadding);
            Assert.Equal(Size.Empty, control.DefaultSize);
            Assert.False(control.DesignMode);
            Assert.Equal(Rectangle.Empty, control.DisplayRectangle);
            Assert.Equal(DockStyle.None, control.Dock);
            Assert.NotNull(control.DockPadding);
            Assert.Same(control.DockPadding, control.DockPadding);
            Assert.Equal(0, control.DockPadding.Top);
            Assert.Equal(0, control.DockPadding.Bottom);
            Assert.Equal(0, control.DockPadding.Left);
            Assert.Equal(0, control.DockPadding.Right);
            Assert.False(control.DoubleBuffered);
            Assert.True(control.Enabled);
            Assert.NotNull(control.Events);
            Assert.Same(control.Events, control.Events);
            Assert.Equal(Control.DefaultFont, control.Font);
            Assert.Equal(control.Font.Height, control.FontHeight);
            Assert.Equal(Control.DefaultForeColor, control.ForeColor);
            Assert.False(control.HasChildren);
            Assert.Equal(0, control.Height);
            Assert.NotNull(control.HorizontalScroll);
            Assert.Same(control.HorizontalScroll, control.HorizontalScroll);
            Assert.False(control.HScroll);
            Assert.Equal(ImeMode.NoControl, control.ImeMode);
            Assert.Equal(ImeMode.NoControl, control.ImeModeBase);
            Assert.Equal(0, control.Left);
            Assert.Equal(Point.Empty, control.Location);
            Assert.Equal(new Padding(3), control.Margin);
            Assert.Equal(Size.Empty, control.MaximumSize);
            Assert.Equal(Size.Empty, control.MinimumSize);
            Assert.Equal(Padding.Empty, control.Padding);
            Assert.Null(control.Parent);
            Assert.Equal(Size.Empty, control.PreferredSize);
            Assert.Equal("Microsoft\u00AE .NET", control.ProductName);
            Assert.False(control.RecreatingHandle);
            Assert.Null(control.Region);
            Assert.False(control.ResizeRedraw);
            Assert.Equal(0, control.Right);
            Assert.Equal(RightToLeft.No, control.RightToLeft);
            Assert.Null(control.Site);
            Assert.Equal(Size.Empty, control.Size);
            Assert.Equal(0, control.TabIndex);
            Assert.True(control.TabStop);
            Assert.Empty(control.Text);
            Assert.Equal(0, control.Top);
            Assert.True(control.Visible);
            Assert.NotNull(control.VerticalScroll);
            Assert.Same(control.VerticalScroll, control.VerticalScroll);
            Assert.False(control.VScroll);
            Assert.Equal(0, control.Width);

            Assert.False(control.IsHandleCreated);
        }
Ejemplo n.º 8
0
 public void ScrollableControl_GetAutoSizeMode_Invoke_ReturnsExpected()
 {
     using var control = new SubScrollableControl();
     Assert.Equal(AutoSizeMode.GrowOnly, control.GetAutoSizeMode());
 }