public void ComboBoxItemAccessibleObject_Bounds_ReturnsCorrect_ForDifferentHeightItems(ComboBoxStyle comboBoxStyle, int itemIndex, Rectangle expectedRect)
        {
            using DifferentHeightComboBox comboBox = new DifferentHeightComboBox();
            comboBox.DropDownStyle = comboBoxStyle;
            comboBox.Items.AddRange(new[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" });
            comboBox.CreateControl();

            if (comboBoxStyle == ComboBoxStyle.Simple)
            {
                comboBox.Size = new Size(100, 400);
            }
            else
            {
                comboBox.Size           = new Size(100, comboBox.Size.Height);
                comboBox.DropDownHeight = 400;
                comboBox.DroppedDown    = true;
            }

            ComboBoxAccessibleObject comboBoxAccessibleObject      = (ComboBoxAccessibleObject)comboBox.AccessibilityObject;
            ComboBoxItemAccessibleObjectCollection itemsCollection = comboBoxAccessibleObject.ItemAccessibleObjects;
            Entry itemEntry = comboBox.Items.InnerList[itemIndex];
            ComboBoxItemAccessibleObject itemAccessibleObject = itemsCollection.GetComboBoxItemAccessibleObject(itemEntry);
            Rectangle actual       = itemAccessibleObject.Bounds;
            Rectangle dropdownRect = comboBox.ChildListAccessibleObject.Bounds;

            Assert.Equal(expectedRect, actual);
        }
        public static IEnumerable <object[]> ComboBoxItemAccessibleObject_Bounds_ReturnsCorrect_ForDifferentHeightItems_TestData()
        {
            foreach (ComboBoxStyle comboBoxStyle in Enum.GetValues(typeof(ComboBoxStyle)))
            {
                // The tested combobox contains 11 items
                for (int index = 0; index < 11; index++)
                {
                    int height = DifferentHeightComboBox.GetCustomItemHeight(index);

                    // We get items rectangles from Windows
                    // It returns to us different expected bounds values depending on a combobox drop-down style
                    int width = comboBoxStyle == ComboBoxStyle.Simple ? 96 : 81;
                    int x     = comboBoxStyle == ComboBoxStyle.Simple ? 10 : 9;
                    int y     = comboBoxStyle == ComboBoxStyle.Simple ? 57 : 56;

                    for (int i = 0; i < index; i++)
                    {
                        y += DifferentHeightComboBox.GetCustomItemHeight(i); // Calculate the sum of heights of all items before the current
                    }

                    yield return(new object[] { comboBoxStyle, index, new Rectangle(x, y, width, height) });
                }
            }
        }