public void MinimumHeight_Set_GetReturnsExpected(int value, int expectedHeight)
        {
            var dataGridView = new DataGridView
            {
                ColumnCount = 1,
                VirtualMode = true
            };
            DataGridViewRow row = dataGridView.Rows[0];

            row.Height = 10;

            int callCount = 0;
            DataGridViewRowHeightInfoNeededEventHandler handler = (sender, e) =>
            {
                callCount++;
                e.MinimumHeight = value;
                Assert.Equal(value, e.MinimumHeight);
                Assert.Equal(expectedHeight, e.Height);
            };

            dataGridView.RowHeightInfoNeeded += handler;

            Assert.Equal(value, row.MinimumHeight);
            Assert.Equal(1, callCount);
        }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// datagridviewrowheightinfoneededeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this DataGridViewRowHeightInfoNeededEventHandler datagridviewrowheightinfoneededeventhandler, Object sender, DataGridViewRowHeightInfoNeededEventArgs e, AsyncCallback callback)
        {
            if (datagridviewrowheightinfoneededeventhandler == null)
            {
                throw new ArgumentNullException("datagridviewrowheightinfoneededeventhandler");
            }

            return(datagridviewrowheightinfoneededeventhandler.BeginInvoke(sender, e, callback, null));
        }
        public void MinimumHeight_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
        {
            var dataGridView = new DataGridView
            {
                ColumnCount = 1,
                VirtualMode = true
            };
            DataGridViewRow row = dataGridView.Rows[0];

            int callCount = 0;
            DataGridViewRowHeightInfoNeededEventHandler handler = (sender, e) =>
            {
                callCount++;
                Assert.Throws <ArgumentOutOfRangeException>("value", () => e.MinimumHeight = value);
            };

            dataGridView.RowHeightInfoNeeded += handler;

            Assert.Equal(3, row.MinimumHeight);
            Assert.Equal(1, callCount);
        }