Example #1
0
        public void TestComboBoxClick_DoesNotEditWhenIndicesAreNegetive()
        {
            //---------------Set up test pack-------------------
            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
            BusinessObjectCollection <MyBO> col;
            IEditableGrid editableGrid = GetGridWith_5_Rows(out col);

            AddComboBoxColumnWithValues(editableGrid);
            ((EditableGridWin)editableGrid).CellClick -= ((EditableGridWin)editableGrid).CellClickHandler;
            IFormHabanero formWin = AddControlToForm(editableGrid);

            formWin.Show();
            editableGrid.CurrentCell = editableGrid.Rows[0].Cells[1];

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, editableGrid.CurrentCell.RowIndex);
            Assert.AreEqual(1, editableGrid.CurrentCell.ColumnIndex);
            System.Windows.Forms.DataGridViewColumn column =
                ((DataGridViewColumnWin)editableGrid.Columns[2]).DataGridViewColumn;
            Assert.IsInstanceOf(typeof(System.Windows.Forms.DataGridViewComboBoxColumn), column);

            //---------------Execute Test ----------------------
            bool setToEditMode = ((EditableGridWin)editableGrid).CheckIfComboBoxShouldSetToEditMode(-1, -1);

            //---------------Test Result -----------------------
            Assert.IsFalse(setToEditMode);
        }
Example #2
0
        public void TestDeleteKeyBehaviours_NoDeleteWhen_SelectedRowsNotZero()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IEditableGrid editableGrid = GetGridWith_5_Rows(out col);

            editableGrid.ConfirmDeletion = true;

            bool confirmationDelegateCalled = false;

            editableGrid.CheckUserConfirmsDeletionDelegate -= editableGrid.CheckUserWantsToDelete;
            editableGrid.CheckUserConfirmsDeletionDelegate += delegate
            {
                confirmationDelegateCalled = true;
                return(true);
            };
            IFormHabanero formWin = AddControlToForm(editableGrid);

            formWin.Show();
            editableGrid.Rows[1].Selected = true;

            //editableGrid.MultiSelect = false;
            //((EditableGridWin)editableGrid).SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            //editableGrid.CurrentCell = editableGrid.Rows[0].Cells[0];

            //---------------Assert Precondition----------------
            Assert.AreEqual(1, editableGrid.SelectedRows.Count);
            //---------------Execute Test ----------------------
            SimulateDeleteKeyPress(editableGrid);

            //---------------Test Result -----------------------
            Assert.IsFalse(confirmationDelegateCalled);
        }
Example #3
0
        public void TestConfirmDeletion_NoDeletionWhenAllowUserToDeleteRowsIsFalse()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IEditableGrid editableGrid = GetGridWith_5_Rows(out col);

            editableGrid.ConfirmDeletion       = true;
            editableGrid.AllowUserToDeleteRows = false;

            bool confirmationDelegateCalled = false;

            editableGrid.CheckUserConfirmsDeletionDelegate -= editableGrid.CheckUserWantsToDelete;
            editableGrid.CheckUserConfirmsDeletionDelegate += delegate
            {
                confirmationDelegateCalled = true;
                return(false);
            };

            IFormHabanero formWin = AddControlToForm(editableGrid);

            formWin.Show();
            //---------------Assert Precondition----------------
            Assert.IsTrue(editableGrid.ConfirmDeletion);
            Assert.IsFalse(editableGrid.AllowUserToDeleteRows);
            //---------------Execute Test ----------------------
            SimulateDeleteKeyPress(editableGrid);

            //---------------Test Result -----------------------
            Assert.IsFalse(confirmationDelegateCalled);
        }
Example #4
0
        public void TestDeleteKeyBehaviours_NoDeleteWhen_IsInEditMode()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IEditableGrid editableGrid = GetGridWith_5_Rows(out col);

            editableGrid.ConfirmDeletion = true;

            bool confirmationDelegateCalled = false;

            editableGrid.CheckUserConfirmsDeletionDelegate -= editableGrid.CheckUserWantsToDelete;
            editableGrid.CheckUserConfirmsDeletionDelegate += delegate
            {
                confirmationDelegateCalled = true;
                return(true);
            };
            editableGrid.CurrentCell = editableGrid.Rows[0].Cells[0];
            editableGrid.BeginEdit(true);
            //---------------Assert Precondition----------------
            Assert.IsTrue(editableGrid.CurrentCell.IsInEditMode);
            //---------------Execute Test ----------------------
            SimulateDeleteKeyPress(editableGrid);

            //---------------Test Result -----------------------
            Assert.IsFalse(confirmationDelegateCalled);
        }
Example #5
0
        public void TestDeleteKeyBehaviours_DeletesNoCells_WhenNoneSelected_WhenUserConfirmsDeletion()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IEditableGrid editableGrid = GetGridWith_5_Rows(out col);

            editableGrid.ConfirmDeletion = true;

            bool confirmationDelegateCalled = false;

            editableGrid.CheckUserConfirmsDeletionDelegate -= editableGrid.CheckUserWantsToDelete;
            editableGrid.CheckUserConfirmsDeletionDelegate += delegate
            {
                confirmationDelegateCalled = true;
                return(true);
            };
            IFormHabanero formWin = AddControlToForm(editableGrid);

            formWin.Show();
            foreach (IDataGridViewCell Cell in editableGrid.SelectedCells)
            {
                Cell.Selected = false;
            }
            //---------------Assert Precondition----------------
            Assert.AreEqual(5, editableGrid.Rows.Count);
            Assert.AreEqual(0, editableGrid.SelectedCells.Count);
            //---------------Execute Test ----------------------

            SimulateDeleteKeyPress(editableGrid);

            //---------------Test Result -----------------------
            Assert.IsTrue(confirmationDelegateCalled);
            Assert.AreEqual(5, editableGrid.Rows.Count);
        }
        public void Test_Set_BusinessObjectCollection_SetupColumnAsCheckBoxType()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWith_Grid_1CheckBoxColumn();
            IBusinessObjectCollection colBOs = GetCol_BO_1CheckboxItem(classDef);
            IEditableGrid             grid   = GetControlFactory().CreateEditableGrid();
            IDataGridViewColumn       dataGridViewColumnSetup = GetControlFactory().CreateDataGridViewCheckBoxColumn();

            SetupGridColumnsForMyBo(grid, dataGridViewColumnSetup);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(1, grid.Columns.Count);
            Assert.AreEqual(1, classDef.UIDefCol.Count);
            IUIGrid uiGridDef = classDef.UIDefCol["default"].UIGrid;

            Assert.IsNotNull(uiGridDef);
            Assert.AreEqual(1, uiGridDef.Count);

            //---------------Execute Test ----------------------
            grid.BusinessObjectCollection = colBOs;
            //---------------Test Result -----------------------
            IDataGridViewColumn dataGridViewColumn = grid.Columns[0];

            AssertIsCheckBoxColumnType(dataGridViewColumn);
            //---------------Tear Down -------------------------
        }
        public void TestSetupColumnAsCheckBoxType()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWith_Grid_1CheckBoxColumn();
            IBusinessObjectCollection colBOs = GetCol_BO_1CheckboxItem(classDef);
            IEditableGrid             grid   = GetControlFactory().CreateEditableGrid();
            IDataGridViewColumn       dataGridViewColumnSetup = GetControlFactory().CreateDataGridViewCheckBoxColumn();

            SetupGridColumnsForMyBo(grid, dataGridViewColumnSetup);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(1, grid.Columns.Count);
            Assert.AreEqual(1, classDef.UIDefCol.Count);
            IUIGrid uiGridDef = classDef.UIDefCol["default"].UIGrid;

            Assert.IsNotNull(uiGridDef);
            Assert.AreEqual(1, uiGridDef.Count);

            //---------------Execute Test ----------------------
#pragma warning disable 618,612// maintained test for backward compatibility testing
            grid.SetBusinessObjectCollection(colBOs);
#pragma warning restore 618,612
            //---------------Test Result -----------------------
            IDataGridViewColumn dataGridViewColumn = grid.Columns[0];
            AssertIsCheckBoxColumnType(dataGridViewColumn);
            //---------------Tear Down -------------------------
        }
Example #8
0
        public void TestDeleteKeyBehaviours_DeletesSelectedCells_OneRow_WithoutConfirmsDeletion()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IEditableGrid editableGrid = GetGridWith_5_Rows(out col);

            editableGrid.ConfirmDeletion = false;

            bool confirmationDelegateCalled = false;

            editableGrid.CheckUserConfirmsDeletionDelegate -= editableGrid.CheckUserWantsToDelete;
            editableGrid.CheckUserConfirmsDeletionDelegate += delegate
            {
                confirmationDelegateCalled = true;
                return(true);
            };
            IFormHabanero formWin = AddControlToForm(editableGrid);

            formWin.Show();
            //---------------Assert Precondition----------------
            Assert.AreEqual(5, editableGrid.Rows.Count);
            //---------------Execute Test ----------------------
            editableGrid.Rows[0].Cells[0].Selected = true;
            SimulateDeleteKeyPress(editableGrid);

            //---------------Test Result -----------------------
            Assert.IsFalse(confirmationDelegateCalled);
            Assert.AreEqual(4, editableGrid.Rows.Count);
        }
        public void Test_SetBusinessObject_BusinessObjectSelectEvent_FiresAndReturnsAValidBO()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGrid editableGrid          = GetControlFactory().CreateEditableGrid();

            AddControlToForm(editableGrid);
            SetupGridColumnsForMyBo(editableGrid);
            editableGrid.BusinessObjectCollection = col;
            IBusinessObject boFromEvent = null;
            bool            eventFired  = false;

            editableGrid.BusinessObjectSelected += delegate(object sender, BOEventArgs e)
            {
                eventFired  = true;
                boFromEvent = e.BusinessObject;
            };
            MyBO myBO = col[2];

            //---------------Execute Test ----------------------
            editableGrid.SelectedBusinessObject = myBO;
            //---------------Test Result -----------------------
            Assert.AreEqual(col.Count + 1, editableGrid.Rows.Count, "should be 4 item 1 adding item");
            Assert.AreSame(myBO, editableGrid.SelectedBusinessObject);
            Assert.IsTrue(eventFired);
            Assert.AreEqual(myBO, boFromEvent);
        }
        protected IEditableGrid GetGridWith_5_Rows(out BusinessObjectCollection <MyBO> col)
        {
            LoadMyBoDefaultClassDef();
            col = CreateCollectionWith_4_Objects();
            IEditableGrid grid = CreateEditableGrid();

            SetupGridColumnsForMyBo(grid);
            grid.BusinessObjectCollection = col;
            return(grid);
        }
        public void TestBasicSettings()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IEditableGrid grid = GetControlFactory().CreateEditableGrid();

            //---------------Test Result -----------------------
            AssertCorrectSelectionMode(grid);
        }
Example #12
0
        public void TestDeleteKeyBehaviours_MessageBoxDelegateAssignedByDefault()
        {
            //---------------Set up test pack-------------------
            IEditableGrid editableGrid = GetControlFactory().CreateEditableGrid();

            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.AreEqual("CheckUserWantsToDelete", editableGrid.CheckUserConfirmsDeletionDelegate.Method.Name);
            //---------------Tear Down -------------------------
        }
Example #13
0
        public void TestDeleteKeyBehaviours_IsDeleteRowByDefault()
        {
            //---------------Set up test pack-------------------
            IEditableGrid editableGrid = GetControlFactory().CreateEditableGrid();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.AreEqual(DeleteKeyBehaviours.DeleteRow, editableGrid.DeleteKeyBehaviour);
        }
Example #14
0
        public void TestDeleteKeyBehaviours_ChangesValue()
        {
            //---------------Set up test pack-------------------
            IEditableGrid editableGrid = GetControlFactory().CreateEditableGrid();

            //---------------Assert Precondition----------------
            Assert.AreEqual(DeleteKeyBehaviours.DeleteRow, editableGrid.DeleteKeyBehaviour);
            //---------------Execute Test ----------------------
            editableGrid.DeleteKeyBehaviour = DeleteKeyBehaviours.ClearContents;
            //---------------Test Result -----------------------
            Assert.AreEqual(DeleteKeyBehaviours.ClearContents, editableGrid.DeleteKeyBehaviour);
        }
        public void TestConfirmDeletion_SetToTrue()
        {
            //---------------Set up test pack-------------------
            IEditableGrid editableGrid = GetControlFactory().CreateEditableGrid();

            //---------------Assert Precondition----------------
            Assert.IsFalse(editableGrid.ConfirmDeletion);
            //---------------Execute Test ----------------------
            editableGrid.ConfirmDeletion = true;
            //---------------Test Result -----------------------
            Assert.IsTrue(editableGrid.ConfirmDeletion);
        }
Example #16
0
        public void TestComboBoxClick_DefaultAndCanSet()
        {
            //---------------Set up test pack-------------------
            IEditableGrid editableGrid = GetControlFactory().CreateEditableGrid();

            //---------------Assert Precondition----------------
            Assert.IsTrue(editableGrid.ComboBoxClickOnce);
            //---------------Execute Test ----------------------
            editableGrid.ComboBoxClickOnce = false;
            //---------------Test Result -----------------------
            Assert.IsFalse(editableGrid.ComboBoxClickOnce);
            //---------------Tear Down -------------------------
        }
Example #17
0
        private static void SimulateDeleteKeyPress(IEditableGrid editableGrid)
        {
            // These four lines are the preferable approach (create an actual Delete key press)
            //   using Nunit's testing framework (see TestControlMapperStrategyWin for a working example)
            //   but there is some deep lying bug_ in Nunit (and there is no GridTester or equivalent)

            //formWin.Show();
            //FormTester box = new FormTester();
            //KeyEventArgs eveArgsDelete = new KeyEventArgs(Keys.Delete);
            //box.FireEvent("KeyUp", eveArgsDelete);

            // Circumvent the above using this (which means that some code will go untested)
            editableGrid.DeleteKeyHandler();
        }
        private static void SimulateDeleteKeyPress(IEditableGrid editableGrid)
        {
            // These four lines are the preferable approach (create an actual Delete key press)
            //   using Nunit's testing framework (see TestControlMapperStrategyWin for a working example)
            //   but there is some deep lying bug_ in Nunit (and there is no GridTester or equivalent)

            //formWin.Show();
            //FormTester box = new FormTester();
            //KeyEventArgs eveArgsDelete = new KeyEventArgs(Keys.Delete);
            //box.FireEvent("KeyUp", eveArgsDelete);

            // Circumvent the above using this (which means that some code will go untested)
            editableGrid.DeleteKeyHandler();
        }
        public void TestSetAllowUsersToAddRowsToFalse()
        {
            //---------------Set up test pack-------------------
            IEditableGrid editableGrid = GetControlFactory().CreateEditableGrid();

            //---------------Assert Precondition----------------
            Assert.IsTrue(editableGrid.AllowUserToAddRows);
            Assert.IsTrue(editableGrid.AllowUserToDeleteRows);
            //---------------Execute Test ----------------------
            editableGrid.AllowUserToAddRows    = false;
            editableGrid.AllowUserToDeleteRows = false;
            //---------------Test Result -----------------------
            Assert.IsFalse(editableGrid.AllowUserToAddRows);
            Assert.IsFalse(editableGrid.AllowUserToDeleteRows);
        }
        public void Test_AutoSelectsFirstItem()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGrid editableGrid          = GetControlFactory().CreateEditableGrid();

            AddControlToForm(editableGrid);
            SetupGridColumnsForMyBo(editableGrid);
            //---------------Execute Test ----------------------
            editableGrid.BusinessObjectCollection = col;
            //---------------Test Result -----------------------
            Assert.AreEqual(col.Count + 1, editableGrid.Rows.Count, "should be 4 item 1 adding item");
            Assert.IsNotNull(editableGrid.SelectedBusinessObject);
        }
        public void TestConstructGrid()
        {
            //---------------Set up test pack-------------------

            //---------------Execute Test ----------------------
            IControlHabanero grid = GetControlFactory().CreateEditableGrid();
            //---------------Test Result -----------------------
            IEditableGrid editableGrid = (IEditableGrid)grid;

            Assert.IsNotNull(editableGrid);
            Assert.IsFalse(editableGrid.ReadOnly);
            Assert.IsTrue(editableGrid.AllowUserToAddRows);
            Assert.IsTrue(editableGrid.AllowUserToDeleteRows);
            //Should we test selection mode
            //---------------Tear Down -------------------------
        }
        public void Test_GetBusinessObjectAtRow_NewRow()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGrid editableGrid          = GetControlFactory().CreateEditableGrid();

            AddControlToForm(editableGrid);
            SetupGridColumnsForMyBo(editableGrid);
            editableGrid.BusinessObjectCollection = col;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IBusinessObject bo = editableGrid.GetBusinessObjectAtRow(4);

            //---------------Test Result -----------------------
            Assert.IsNull(bo);
        }
        public void Test_GetBusinessObjectAtRow_WhenBOColNull_ShouldReturnNull()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            CreateCollectionWith_4_Objects();
            IEditableGrid editableGrid = GetControlFactory().CreateEditableGrid();

            AddControlToForm(editableGrid);
            SetupGridColumnsForMyBo(editableGrid);
            //---------------Assert Precondition----------------
            Assert.IsNull(editableGrid.BusinessObjectCollection);
            //---------------Execute Test ----------------------
            IBusinessObject bo = editableGrid.GetBusinessObjectAtRow(0);

            //---------------Test Result -----------------------
            Assert.IsNull(bo);
        }
        protected void AddComboBoxColumnWithValues(IEditableGrid editableGrid)
        {
            DataTable table = new DataTable();

            table.Columns.Add("id");
            table.Columns.Add("str");

            table.LoadDataRow(new object[] { "", "" }, true);
            table.LoadDataRow(new object[] { "asdfsdf", "A" }, true);
            table.LoadDataRow(new object[] { "shasdfg", "B" }, true);

            IDataGridViewComboBoxColumn column = GetControlFactory().CreateDataGridViewComboBoxColumn();

            column.DataSource = table;

            SetupGridColumnsForMyBo(editableGrid, column);
        }
Example #25
0
        protected override int SelectedIndex(IBOColSelectorControl colSelector)
        {
            IEditableGrid    gridSelector = ((IEditableGridControl)colSelector).Grid;
            IDataGridViewRow currentRow   = null;

            if (gridSelector.SelectedRows.Count > 0)
            {
                currentRow = gridSelector.SelectedRows[0];
            }

            if (currentRow == null)
            {
                return(-1);
            }

            return(gridSelector.Rows.IndexOf(currentRow));
        }
Example #26
0
        public void TestComboBoxClick_DoesNotAffectOtherColumnType()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IEditableGrid editableGrid = GetGridWith_5_Rows(out col);

            ((EditableGridWin)editableGrid).CellClick -= ((EditableGridWin)editableGrid).CellClickHandler;
            IFormHabanero formWin = AddControlToForm(editableGrid);

            formWin.Show();
            //---------------Assert Precondition----------------
            Assert.IsNotInstanceOf(typeof(IDataGridViewComboBoxColumn), editableGrid.Columns[0]);
            //---------------Execute Test ----------------------
            bool setToEditMode = ((EditableGridWin)editableGrid).CheckIfComboBoxShouldSetToEditMode(0, 0);

            //---------------Test Result -----------------------
            Assert.IsFalse(setToEditMode);
        }
 ///<summary>
 /// Constructs a new instance of a <see cref="EditableGridControlVWG"/>.
 ///</summary>
 ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
 public EditableGridControlVWG(IControlFactory controlFactory)
 {
     if (controlFactory == null) throw new HabaneroArgumentException("controlFactory", 
             "Cannot create an editable grid control if the control factory is null");
     _controlFactory = controlFactory;
     _grid = _controlFactory.CreateEditableGrid();
     _editableGridManager = new EditableGridControlManager(this, controlFactory);
     Buttons = _controlFactory.CreateEditableGridButtonsControl();
     FilterControl = _controlFactory.CreateFilterControl();
     InitialiseButtons();
     InitialiseFilterControl();
     BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(this);
     manager.AddControl(FilterControl, BorderLayoutManager.Position.North);
     manager.AddControl(_grid, BorderLayoutManager.Position.Centre);
     manager.AddControl(Buttons, BorderLayoutManager.Position.South);
     this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;
     this.AllowUsersToAddBO = true;
 }
        public void Test_SelectIndex_SetsSelectedBO()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGrid editableGrid          = GetControlFactory().CreateEditableGrid();

            AddControlToForm(editableGrid);
            SetupGridColumnsForMyBo(editableGrid);
            editableGrid.BusinessObjectCollection = col;
            MyBO myBO = col[2];

            //---------------Execute Test ----------------------
            editableGrid.Rows[2].Selected = true;
            //---------------Test Result -----------------------
            Assert.AreEqual(col.Count + 1, editableGrid.Rows.Count, "should be 4 item 1 adding item");
            Assert.AreSame(myBO, editableGrid.SelectedBusinessObject);
        }
        public void Test_SetBusinessObjectCollection_NumberOfGridRows_Correct()
        {
            //---------------Set up test pack-------------------
            LoadMyBoDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

            AddControlToForm(editableGridControl);
            IEditableGrid editableGrid = editableGridControl.Grid;

            editableGrid.Columns.Add("TestProp", "TestProp");

            //--------------Assert PreConditions----------------
            Assert.AreEqual(1, editableGrid.Rows.Count);

            //---------------Execute Test ----------------------
            editableGridControl.SetBusinessObjectCollection(col);
            ////---------------Test Result -----------------------
            Assert.AreEqual(col.Count + 1, editableGrid.Rows.Count, "The number of items in the grid plus the null item");
        }
Example #30
0
        protected override void SetSelectedIndex(IBOColSelectorControl colSelector, int index)
        {
            int count = 0;

            IEditableGrid grid = ((IEditableGridControl)colSelector).Grid;

            foreach (IDataGridViewRow row in grid.Rows)
            {
                if (row == null)
                {
                    continue;              //This is done to stop the Pragma warning.
                }
                if (count == index)
                {
                    IBusinessObject businessObjectAtRow = grid.GetBusinessObjectAtRow(count);
                    colSelector.SelectedBusinessObject = businessObjectAtRow;
                }
                count++;
            }
        }
Example #31
0
        ///<summary>
        /// Constructs a new instance of a <see cref="EditableGridControlVWG"/>.
        ///</summary>
        ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
        public EditableGridControlVWG(IControlFactory controlFactory)
        {
            if (controlFactory == null)
            {
                throw new HabaneroArgumentException("controlFactory",
                                                    "Cannot create an editable grid control if the control factory is null");
            }
            _controlFactory      = controlFactory;
            _grid                = _controlFactory.CreateEditableGrid();
            _editableGridManager = new EditableGridControlManager(this, controlFactory);
            Buttons              = _controlFactory.CreateEditableGridButtonsControl();
            FilterControl        = _controlFactory.CreateFilterControl();
            InitialiseButtons();
            InitialiseFilterControl();
            BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(this);

            manager.AddControl(FilterControl, BorderLayoutManager.Position.North);
            manager.AddControl(_grid, BorderLayoutManager.Position.Centre);
            manager.AddControl(Buttons, BorderLayoutManager.Position.South);
            this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;
            this.AllowUsersToAddBO            = true;
        }
        public void Test_SetBusinessObjectCollection_WhenAllowAddFalse_ShouldNotChangeAllowAdd()
        {
            //---------------Set up test pack-------------------
            LoadMyBoDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

            AddControlToForm(editableGridControl);
            IEditableGrid editableGrid = editableGridControl.Grid;

            editableGrid.Columns.Add("TestProp", "TestProp");
            editableGridControl.AllowUsersToAddBO = false;
            //--------------Assert PreConditions----------------
            Assert.AreEqual(0, editableGrid.Rows.Count);
            Assert.IsFalse(editableGrid.AllowUserToAddRows);
            //---------------Execute Test ----------------------
            editableGridControl.SetBusinessObjectCollection(col);
            ////---------------Test Result -----------------------
            Assert.IsFalse(editableGrid.AllowUserToAddRows);
            Assert.IsFalse(editableGridControl.AllowUsersToAddBO);
            Assert.AreEqual(col.Count, editableGrid.Rows.Count, "The number of items in the col");
        }
        protected void AddComboBoxColumnWithValues(IEditableGrid editableGrid)
        {
            DataTable table = new DataTable();
            table.Columns.Add("id");
            table.Columns.Add("str");

            table.LoadDataRow(new object[] {"", ""}, true);
            table.LoadDataRow(new object[] {"asdfsdf", "A"}, true);
            table.LoadDataRow(new object[] {"shasdfg", "B"}, true);

            IDataGridViewComboBoxColumn column = GetControlFactory().CreateDataGridViewComboBoxColumn();
            column.DataSource = table;

            SetupGridColumnsForMyBo(editableGrid, column);
        }