public void DataGridViewCellAccessibleObject_Name_ReturnStringEmpty_IfOwningRowAndColumnNotExist()
        {
            SubDataGridViewCell cell             = new SubDataGridViewCell();
            AccessibleObject    accessibleObject = new DataGridViewCellAccessibleObject(cell);

            Assert.Equal(string.Empty, accessibleObject.Name);
        }
        public void DataGridViewCellAccessibleObject_Ctor_Default()
        {
            var accessibleObject = new DataGridViewCellAccessibleObject();

            Assert.Null(accessibleObject.Owner);
            Assert.Equal(AccessibleRole.Cell, accessibleObject.Role);
        }
        public void DataGridViewCellAccessibleObject_Select_NothingToDo_Nop(AccessibleSelection flags)
        {
            using var owner = new SubDataGridViewCell();
            var accessibleObject = new DataGridViewCellAccessibleObject(owner);

            accessibleObject.Select(flags);
        }
        public void DataGridViewCellAccessibleObject_Ctor_DataGridViewCell(DataGridViewCell owner)
        {
            var accessibleObject = new DataGridViewCellAccessibleObject(owner);

            Assert.Equal(owner, accessibleObject.Owner);
            Assert.Equal(AccessibleRole.Cell, accessibleObject.Role);
        }
        public void DataGridViewCellAccessibleObject_Select_TakeFocus()
        {
            using var dataGridView = new SubDataGridView();
            dataGridView.CreateControl();
            Assert.True(dataGridView.IsHandleCreated);

            var mockCell = new Mock <DataGridViewCell>(MockBehavior.Strict);

            mockCell
            .SetupSet(s => s.State = DataGridViewElementStates.Visible)
            .Verifiable();
            mockCell
            .Protected()
            .Setup("Dispose", ItExpr.IsAny <bool>());
            mockCell
            .Protected()
            .Setup("OnDataGridViewChanged");

            var mockObj = mockCell.Object;

            mockObj.DataGridView = dataGridView;

            var accessibleObject = new DataGridViewCellAccessibleObject(mockObj);

            // verify that we check for a flag, not direct comparison. 128 is an arbitrary large flag.
            accessibleObject.Select((AccessibleSelection)128 | AccessibleSelection.TakeFocus);

            // NB: some asserts are implicit - check that nothing was called on the mock that we didn't anticipate
            Assert.True(dataGridView.FocusCalled);
            Assert.True(dataGridView.IsHandleCreated);
        }
        public void DataGridViewCellAccessibleObject_Select_TakeSelection()
        {
            using var dataGridView = new DataGridView();
            dataGridView.CreateControl();
            Assert.True(dataGridView.IsHandleCreated);

            var mockCell = new Mock <DataGridViewCell>(MockBehavior.Strict);

            mockCell
            .SetupSet(s => s.State = DataGridViewElementStates.Visible)
            .Verifiable();
            mockCell
            .SetupSet(s => s.Selected = true)
            .Verifiable();
            mockCell
            .Protected()
            .Setup("Dispose", ItExpr.IsAny <bool>());
            mockCell
            .Protected()
            .Setup("OnDataGridViewChanged");

            var mockObj = mockCell.Object;

            mockObj.DataGridView = dataGridView;

            var accessibleObject = new DataGridViewCellAccessibleObject(mockObj);

            // verify that we check for a flag, not direct comparison. 128 is an arbitrary large flag.
            accessibleObject.Select((AccessibleSelection)128 | AccessibleSelection.TakeSelection);

            // NB: some asserts are implicit - check that nothing was called on the mock that we didn't anticipate

            // Can't test whether CurrentCell was set unless we add the whole layer of Rows, Columns, etc.
            // Assert.Equal(mockObj, dataGridView.CurrentCell);
        }
        public void DataGridViewCellAccessibleObject_Select_HasSelectionFlagsWithoutValidDataGridView_DoesNothing()
        {
            var mockCell = new Mock <DataGridViewCell>(MockBehavior.Strict);

            mockCell
            .SetupSet(s => s.State = DataGridViewElementStates.Visible)
            .Verifiable();
            mockCell
            .Protected()
            .Setup("Dispose", ItExpr.IsAny <bool>());

            var mockObj          = mockCell.Object;
            var accessibleObject = new DataGridViewCellAccessibleObject(mockObj);

            accessibleObject.Select(AccessibleSelection.None);
            // NB: asserts are implicit - check that nothing was called on the mock that we didn't anticipate

            using DataGridView dataGridView = new DataGridView();
            mockCell
            .Protected()
            .Setup("OnDataGridViewChanged");
            mockObj.DataGridView = dataGridView;

            accessibleObject.Select(AccessibleSelection.None);
            // NB: asserts are implicit - check that nothing was called on the mock that we didn't anticipate
        }
        public void DataGridViewCellAccessibleObject_GetChildCount_NoDataGridView_ReturnsZero()
        {
            using var owner = new SubDataGridViewCell();
            var accessibleObject = new DataGridViewCellAccessibleObject(owner);

            Assert.Equal(0, accessibleObject.GetChildCount());
        }
        public void DataGridViewCellAccessibleObject_GetChild_NoDataGridView_ReturnsNull()
        {
            using var owner = new SubDataGridViewCell();
            var accessibleObject = new DataGridViewCellAccessibleObject(owner);

            Assert.Null(accessibleObject.GetChild(-1));
        }
        public void DataGridViewCellAccessibleObject_State_NoDataGridView_ReturnsExpected()
        {
            using var owner = new SubDataGridViewCell();
            var accessibleObject = new DataGridViewCellAccessibleObject(owner);

            Assert.Equal(AccessibleStates.Focusable | AccessibleStates.Selectable, accessibleObject.State);
        }
        public void DataGridViewCellAccessibleObject_Owner_SetAlreadyWithOwner_ThrowsInvalidOperationException()
        {
            using var owner = new SubDataGridViewCell();
            var accessibleObject = new DataGridViewCellAccessibleObject(owner);

            Assert.Throws <InvalidOperationException>(() => accessibleObject.Owner = owner);
        }
        public void DataGridViewCellAccessibleObject_Owner_Set_GetReturnsExpected()
        {
            using var owner = new SubDataGridViewCell();
            var accessibleObject = new DataGridViewCellAccessibleObject
            {
                Owner = owner
            };

            Assert.Same(owner, accessibleObject.Owner);
        }
        public void DataGridViewCellAccessibleObject_Name_ReturnExpected_IfDataGridViewNotExist()
        {
            SubDataGridViewCell cell = new SubDataGridViewCell();

            cell.OwningRow    = new DataGridViewRow();
            cell.OwningColumn = new DataGridViewTextBoxColumn()
            {
                HeaderText = "Test", SortMode = DataGridViewColumnSortMode.NotSortable
            };
            AccessibleObject accessibleObject = new DataGridViewCellAccessibleObject(cell);
            string           expected         = string.Format(SR.DataGridView_AccDataGridViewCellName, cell.OwningColumn.HeaderText, -1);

            Assert.Equal(expected, accessibleObject.Name);
        }
Beispiel #14
0
        public void DataGridViewCellAccessibleObject_Select_RemoveSelection()
        {
            using var dataGridView = new DataGridView();
            dataGridView.CreateControl();
            Assert.True(dataGridView.IsHandleCreated);

            var mockCell = new Mock <DataGridViewCell>(MockBehavior.Strict);

            mockCell
            .SetupSet(s => s.State = DataGridViewElementStates.Visible)
            .Verifiable();
            mockCell
            .SetupSet(s => s.Selected = It.IsAny <bool>())
            .Verifiable();
            mockCell
            .Protected()
            .Setup("Dispose", ItExpr.IsAny <bool>());
            mockCell
            .Protected()
            .Setup("OnDataGridViewChanged");

            mockCell.Object.DataGridView = dataGridView;

            var accessibleObject = new DataGridViewCellAccessibleObject(mockCell.Object);

            // set selection, RemoveSelection is ignored
            accessibleObject.Select(AccessibleSelection.AddSelection | AccessibleSelection.RemoveSelection);
            // set selection, RemoveSelection is ignored
            accessibleObject.Select(AccessibleSelection.TakeSelection | AccessibleSelection.RemoveSelection);
            // now remove the selection
            accessibleObject.Select(AccessibleSelection.RemoveSelection);

            // NB: asserts are implicit - check that nothing was called on the mock that we didn't anticipate
            mockCell.VerifySet(s => s.Selected = true, Times.Exactly(2));
            mockCell.VerifySet(s => s.Selected = false, Times.Once());
        }
        public void DataGridViewCellAccessibleObject_Help_Get_ReturnsNull()
        {
            var accessibleObject = new DataGridViewCellAccessibleObject();

            Assert.Null(accessibleObject.Help);
        }
        public void DataGridViewCellAccessibleObject_GetSelected_Invoke_ReturnsNull()
        {
            var accessibleObject = new DataGridViewCellAccessibleObject();

            Assert.Null(accessibleObject.GetSelected());
        }
Beispiel #17
0
        public void DataGridViewCellAccessibleObject_ControlType_IsDefined()
        {
            UiaCore.IRawElementProviderSimple provider = new DataGridViewCellAccessibleObject();

            Assert.Equal(UiaCore.UIA.DataItemControlTypeId, provider.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId));
        }
        public void DataGridViewCellAccessibleObject_Сolumn_ReturnExpected_IfOwningColumnNotExist()
        {
            AccessibleObject accessibleObject = new DataGridViewCellAccessibleObject(new SubDataGridViewCell());

            Assert.Equal(-1, accessibleObject.Column);
        }
        public void DataGridViewCellAccessibleObject_Row_ReturnExpected_IfOwningRowNotExist()
        {
            AccessibleObject accessibleObject = new DataGridViewCellAccessibleObject(new SubDataGridViewCell());

            Assert.Equal(-1, accessibleObject.Row);
        }