public void ListViewInsertionMark_NearestIndex_NoSuchPoint_ReturnsInvalid()
        {
            var listView = new ListView();
            ListViewInsertionMark insertionMark = listView.InsertionMark;

            Assert.True(insertionMark.NearestIndex(new Point(-10, -11)) >= -1);
        }
        public void ListViewInsertionMark_NearestIndex_NoSuchPointWithoutHandle_ReturnsInvalid()
        {
            using var control = new ListView();
            ListViewInsertionMark insertionMark = control.InsertionMark;

            Assert.True(insertionMark.NearestIndex(new Point(-10, -11)) >= -1);
            Assert.True(control.IsHandleCreated);
        }
        public void ListViewInsertionMark_NearestIndex_InvokeCustomInsertMarkHitTest_ReturnsExpected(int result)
        {
            using var control = new CustomInsertMarkHitTestListView
                  {
                      InsertMarkHitTestResult = result
                  };
            ListViewInsertionMark insertionMark = control.InsertionMark;

            Assert.Equal(result, insertionMark.NearestIndex(new Point(1, 2)));
        }
        public void ListViewInsertionMark_NearestIndex_NoSuchPointWithHandle_ReturnsInvalid()
        {
            using var control = new ListView();
            ListViewInsertionMark insertionMark = control.InsertionMark;

            Assert.NotEqual(IntPtr.Zero, control.Handle);
            int invalidatedCallCount = 0;

            control.Invalidated += (sender, e) => invalidatedCallCount++;
            int styleChangedCallCount = 0;

            control.StyleChanged += (sender, e) => styleChangedCallCount++;
            int createdCallCount = 0;

            control.HandleCreated += (sender, e) => createdCallCount++;

            Assert.True(insertionMark.NearestIndex(new Point(-10, -11)) >= -1);
            Assert.True(control.IsHandleCreated);
            Assert.Equal(0, invalidatedCallCount);
            Assert.Equal(0, styleChangedCallCount);
            Assert.Equal(0, createdCallCount);
        }