예제 #1
0
        public virtual void TestInitGrid_LoadsDataGridViewComboBoxColumn_WhenPropDefMissing()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef = MyBO.LoadClassDefWith_Grid_1ComboBoxColumn();
            IEditableGridControl grid     = GetControlFactory().CreateEditableGridControl();

            DisposeOnTearDown(grid);
            IGridInitialiser initialiser   = new GridInitialiser(grid, GetControlFactory());
            IUIDef           uiDef         = classDef.UIDefCol["default"];
            IUIGrid          uiGridDef     = uiDef.UIGrid;
            IUIGridColumn    uiComboColDef = uiGridDef[0];

            uiComboColDef.GridControlTypeName = "DataGridViewComboBoxColumn";
            uiComboColDef.PropertyName        = "OtherProp";
            AddControlToForm(grid);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, grid.Grid.Columns.Count);
            IDataGridViewColumn column1 = grid.Grid.Columns[1];

            Assert.AreEqual("OtherProp", column1.Name);
            Assert.AreEqual(uiComboColDef.Heading, column1.HeaderText);
            Assert.IsInstanceOf(typeof(IDataGridViewComboBoxColumn), column1);
            AssertGridColumnTypeAfterCast(column1, GetComboBoxGridColumnType());
        }
        public void Test_SetBusinessObjectCollection_Null_ClearsTheGrid()
        {
            //---------------Set up test pack-------------------
            LoadMyBoDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

            AddControlToForm(editableGridControl);
            editableGridControl.Grid.Columns.Add("TestProp", "TestProp");

            editableGridControl.SetBusinessObjectCollection(col);

            //----------------Assert Preconditions --------------

            Assert.IsTrue(editableGridControl.Grid.Rows.Count > 0, "There should be items in teh grid b4 clearing");
            //---------------Execute Test ----------------------
            editableGridControl.SetBusinessObjectCollection(null);
            //---------------Verify Result ---------------------
            Assert.AreEqual(0, editableGridControl.Grid.Rows.Count,
                            "There should be no items in the grid  after setting to null");

            Assert.IsFalse(editableGridControl.Buttons.Enabled);
            Assert.IsFalse(editableGridControl.FilterControl.Enabled);
            Assert.IsFalse(editableGridControl.Grid.AllowUserToAddRows);
        }
예제 #3
0
        public void Test_Acceptance_Filter_When_On_Page2_Of_Pagination()
        {
            //---------------Set up test pack-------------------
            //Get Grid with 4 items
            BusinessObjectCollection <MyBO> col;
            IEditableGridControl            gridControl = GetGridWith_5_Rows(out col);

            AddControlToForm(gridControl);
            ITextBox tb = gridControl.FilterControl.AddStringFilterTextBox("Test Prop", "TestProp");

            //Set items per page to 3 items
            gridControl.Grid.ItemsPerPage = 3;
            //Go to page 2 (pagination page)
            gridControl.Grid.CurrentPage = 2;

            //--------------Assert PreConditions ---------------
            Assert.AreEqual(2, gridControl.Grid.CurrentPage);
            //---------------Execute Test ----------------------
            //enter data in filter for 1 item
            tb.Text = "b";
            gridControl.FilterControl.ApplyFilter();
            //---------------Test Result -----------------------
            // verify that grid has moved back to page 1
            Assert.AreEqual(1, gridControl.Grid.CurrentPage);
            //---------------Tear Down -------------------------
        }
예제 #4
0
        public virtual void TestInitGrid_LoadsDataGridViewDateTimeColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef = MyBO.LoadClassDefWithDateTimeParameterFormat();
            IEditableGridControl grid     = GetControlFactory().CreateEditableGridControl();

            DisposeOnTearDown(grid);
            IGridInitialiser initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef           uiDef       = classDef.UIDefCol["default"];
            IUIGrid          uiGridDef   = uiDef.UIGrid;
            IUIGridColumn    uiDTColDef  = uiGridDef[2];

            uiDTColDef.GridControlTypeName = "DataGridViewDateTimeColumn";
            AddControlToForm(grid);

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

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            //---------------Test Result -----------------------
            Assert.AreEqual(6, grid.Grid.Columns.Count);
            IDataGridViewColumn column3 = grid.Grid.Columns[3];

            Assert.AreEqual("TestDateTime", column3.Name);
            Assert.AreEqual(uiDTColDef.Heading, column3.HeaderText);
            Assert.IsInstanceOf(typeof(IDataGridViewColumn), column3);
            AssertGridColumnTypeAfterCast(column3, GetDateTimeGridColumnType());
        }
        public void Test_EditInTextbox_FirstRow()
        {
            //---------------Set up test pack-------------------
            IEditableGridControl grid = GetControlFactory().CreateEditableGridControl();

            MyBO.LoadDefaultClassDef();
            IClassDef def = ClassDef.ClassDefs[typeof(MyBO)];

            grid.Initialise(def);
            BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>();

            //--------------Assert PreConditions----------------
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            //---------------Execute Test ----------------------
            grid.Grid.BusinessObjectCollection = col;
            const string testvalue = "testvalue";

            grid.Grid.Rows[0].Cells[1].Value = testvalue;
//            grid.ApplyChangesToBusinessObject();
            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.CreatedBusinessObjects.Count);
            MyBO newBo = col.CreatedBusinessObjects[0];

            Assert.AreEqual(testvalue, newBo.TestProp);
        }
예제 #6
0
        /// <summary>
        /// Creates a panel with a grid containing the business object
        /// information
        /// </summary>
        /// <param name="formGrid">The grid to fill</param>
        /// <returns>Returns the object containing the panel</returns>
        private PanelFactoryInfo CreatePanelWithGrid(IUIFormGrid formGrid)
        {
            IEditableGridControl myGrid = _controlFactory.CreateEditableGridControl();

            BusinessObject  bo              = _currentBusinessObject;
            ClassDef        classDef        = bo.ClassDef;
            DataSetProvider dataSetProvider = myGrid.Grid.DataSetProvider as DataSetProvider;

            if (dataSetProvider != null)
            {
                dataSetProvider.ObjectInitialiser =
                    new RelationshipObjectInitialiser(bo, (RelationshipDef)classDef.GetRelationship(formGrid.RelationshipName),
                                                      formGrid.CorrespondingRelationshipName);
            }
            IBusinessObjectCollection collection =
                bo.Relationships.GetRelatedCollection(formGrid.RelationshipName);

            myGrid.SetBusinessObjectCollection(collection);

            myGrid.Dock = DockStyle.Fill;
            IPanel panel = _controlFactory.CreatePanel(formGrid.RelationshipName, _controlFactory);

            panel.Controls.Add(myGrid);

            PanelFactoryInfo panelFactoryInfo = new PanelFactoryInfo(panel);

            panelFactoryInfo.FormGrids.Add(formGrid.RelationshipName, myGrid);
            return(panelFactoryInfo);
        }
        public void TestConstructor()
        {
            //---------------Set up test pack-------------------
            //---------------Execute Test ----------------------
            IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl();

            gridControl.Width  = 200;
            gridControl.Height = 133;
            //---------------Test Result -----------------------
            Assert.IsNotNull(gridControl);
            Assert.IsNotNull(gridControl.Grid);
            Assert.AreSame(gridControl.Grid, gridControl.Grid);
            Assert.AreEqual(3, gridControl.Controls.Count);
            Assert.AreEqual(gridControl.Width, gridControl.Grid.Width);
            int addedControlHeights = gridControl.FilterControl.Height +
                                      gridControl.Grid.Height +
                                      gridControl.Buttons.Height;

            Assert.AreEqual(gridControl.Height, addedControlHeights);


            Assert.IsFalse(gridControl.Grid.ReadOnly);
            Assert.IsTrue(gridControl.Grid.AllowUserToAddRows);
            Assert.IsTrue(gridControl.Grid.AllowUserToDeleteRows);
            //---------------Tear Down -------------------------
        }
        public void Test_SetBusinessObject_BusinessObjectSelectEvent_FiresAndReturnsAValidBO()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

            AddControlToForm(editableGridControl);
            SetupGridColumnsForMyBo(editableGridControl.Grid);
            editableGridControl.BusinessObjectCollection = col;
            IBusinessObject boFromEvent = null;

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

            //---------------Execute Test ----------------------
            editableGridControl.SelectedBusinessObject = myBO;
            //---------------Test Result -----------------------
            Assert.AreEqual(col.Count + 1, editableGridControl.Grid.Rows.Count, "should be 4 item 1 adding item");
            Assert.AreSame(myBO, editableGridControl.SelectedBusinessObject);
            Assert.AreEqual(myBO, boFromEvent);
        }
        public void TestFixBug_SearchGridSearchesTheGrid_DoesNotCallFilterOnGridbase()
        {
            //FirstName is not in the grid def therefore if the grid calls the filter gridbase filter
            // the dataview will try to filter with a column that does not exist this will raise an error
            //---------------Set up test pack-------------------
            //Clear all contact people from the DB
            ContactPerson.DeleteAllContactPeople();
            IClassDef classDef = ContactPersonTestBO.LoadDefaultClassDefWithUIDef();

            CreateContactPersonInDB();

            //Create grid setup for search
            IEditableGridControl gridControl = CreateEditableGridControl();

            ITextBox txtboxFirstName = gridControl.FilterControl.AddStringFilterTextBox("FirstName", "FirstName");

            gridControl.Initialise(classDef);
            gridControl.FilterMode = FilterModes.Search;
            //---------------Execute Test ----------------------
            txtboxFirstName.Text = "FFF";
            gridControl.FilterControl.ApplyFilter();
            //---------------Test Result -----------------------
            Assert.IsTrue(true); //No error was thrown by the grid.
            //---------------Tear Down -------------------------
        }
        public void Test_BusinessObjectSelectEvent()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

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

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

            //---------------Execute Test ----------------------
            editableGridControl.Grid.Rows[2].Selected = true;
            //---------------Test Result -----------------------
            Assert.IsTrue(eventFired, "Selected event should have been fired");
            Assert.AreEqual(col.Count + 1, editableGridControl.Grid.Rows.Count, "should be 4 item 1 adding item");
            Assert.AreSame(myBO, editableGridControl.SelectedBusinessObject);
            Assert.AreEqual(myBO, boFromEvent);
        }
예제 #11
0
        public void TestSelectTwoTreeNodes()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            IClassDef classDef1 = MyBO.LoadDefaultClassDef();
            IClassDef classDef2 = ContactPersonTestBO.LoadDefaultClassDefWithUIDef();

            IFormHabanero        frm;
            IStaticDataEditor    editor      = CreateEditorOnForm(out frm);
            IEditableGridControl gridControl = (IEditableGridControl)editor.Controls[0];

            editor.AddSection(TestUtil.GetRandomString());
            string itemName1 = TestUtil.GetRandomString();

            editor.AddItem(itemName1, classDef1);
            string itemName2 = TestUtil.GetRandomString();

            editor.AddItem(itemName2, classDef2);
            editor.SelectItem(itemName1);

            //---------------Assert Preconditions---------------
            Assert.IsNotNull(gridControl.Grid.BusinessObjectCollection);
            Assert.AreSame(classDef1, gridControl.Grid.BusinessObjectCollection.ClassDef);

            //---------------Execute Test ----------------------
            editor.SelectItem(itemName2);

            //---------------Test Result -----------------------
            Assert.IsNotNull(gridControl.Grid.BusinessObjectCollection);
            Assert.AreSame(classDef2, gridControl.Grid.BusinessObjectCollection.ClassDef);
            //---------------Tear Down -------------------------
            TearDownForm(frm);
        }
예제 #12
0
        public virtual void TestSaveChanges()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            IClassDef classDef1 = MyBO.LoadDefaultClassDef();
            MyBO      myBO      = new MyBO();

            myBO.Save();
            IFormHabanero        frm;
            IStaticDataEditor    editor      = CreateEditorOnForm(out frm);
            IEditableGridControl gridControl = (IEditableGridControl)editor.Controls[0];

            editor.AddSection(TestUtil.GetRandomString());
            string itemName1 = TestUtil.GetRandomString();

            editor.AddItem(itemName1, classDef1);
            editor.SelectItem(itemName1);
            gridControl.Grid.SelectedBusinessObject = myBO;
            string newValue = TestUtil.GetRandomString();

            //---------------Execute Test ----------------------
            gridControl.Grid.CurrentRow.Cells["TestProp"].Value = newValue;
            bool result = editor.SaveChanges();

            //---------------Test Result -----------------------
            Assert.IsTrue(result);
            BusinessObjectCollection <MyBO> collection = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection <MyBO>("");

            Assert.AreEqual(1, collection.Count);
            Assert.AreEqual(newValue, myBO.TestProp);
            Assert.IsFalse(myBO.Status.IsDirty);
            //---------------Tear Down -------------------------
            TearDownForm(frm);
        }
예제 #13
0
        public void TestSelectSectionThenItemNode()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            IClassDef            classDef = MyBO.LoadDefaultClassDef();
            IFormHabanero        frm;
            IStaticDataEditor    editor      = CreateEditorOnForm(out frm);
            IEditableGridControl gridControl = (IEditableGridControl)editor.Controls[0];

            editor.AddSection(TestUtil.GetRandomString());
            string itemName = TestUtil.GetRandomString();

            editor.AddItem(itemName, classDef);
            ITreeView treeView = (ITreeView)editor.Controls[1];

            //---------------Execute Test ----------------------
            treeView.SelectedNode = treeView.Nodes[0];

            treeView.SelectedNode = treeView.Nodes[0].Nodes[0];

            //---------------Test Result -----------------------
            Assert.IsTrue(gridControl.Grid.Enabled);
            //---------------Tear Down -------------------------
            TearDownForm(frm);
        }
예제 #14
0
        public void TestAddTwoItemsAndSelectSecondItem()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            IClassDef classDef = MyBO.LoadDefaultClassDef();

            ClassDef.ClassDefs.Clear();
            IClassDef            classDef2 = MyBO.LoadClassDefWithBoolean();
            IFormHabanero        frm;
            IStaticDataEditor    editor      = CreateEditorOnForm(out frm);
            IEditableGridControl gridControl = (IEditableGridControl)editor.Controls[0];

            editor.AddSection(TestUtil.GetRandomString());
            string itemName  = TestUtil.GetRandomString();
            string itemName2 = TestUtil.GetRandomString();

            editor.AddItem(itemName, classDef);
            editor.AddItem(itemName2, classDef2);
            //---------------Execute Test ----------------------
            editor.SelectItem(itemName);
            editor.SelectItem(itemName2);

            //---------------Test Result -----------------------
            Assert.IsNotNull(gridControl.Grid.BusinessObjectCollection);
            Assert.AreSame(classDef2, gridControl.Grid.BusinessObjectCollection.ClassDef);
            //---------------Tear Down -------------------------
            TearDownForm(frm);
        }
예제 #15
0
        public void TestInitGrid_LoadsCustomColumnType()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef    = MyBO.LoadClassDefWithDateTimeParameterFormat();
            IEditableGridControl grid        = GetControlFactory().CreateEditableGridControl();
            IGridInitialiser     initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef  uiDef     = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;

            Type customColumnType = typeof(CustomDataGridViewColumnVWG);

            uiGridDef[2].GridControlTypeName     = customColumnType.Name; //"CustomDataGridViewColumn";
            uiGridDef[2].GridControlAssemblyName = "Habanero.Faces.Test.VWG";
            AddControlToForm(grid);

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

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            //---------------Test Result -----------------------
            Assert.AreEqual(6, grid.Grid.Columns.Count);
            IDataGridViewColumn column3 = grid.Grid.Columns[3];

            Assert.AreEqual("TestDateTime", column3.Name);
            Assert.IsInstanceOf(typeof(IDataGridViewColumn), column3);
            AssertGridColumnTypeAfterCast(column3, customColumnType);
        }
        public void Test_SetBusinessObjectCollection_NullCol_ThenNonNullEnablesButtons()
        {
            //---------------Set up test pack-------------------
            LoadMyBoDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

            AddControlToForm(editableGridControl);
            editableGridControl.AllowUsersToAddBO = true;
            editableGridControl.SetBusinessObjectCollection(col);
            Assert.IsTrue(editableGridControl.Grid.AllowUserToAddRows);
            editableGridControl.SetBusinessObjectCollection(null);
            //----------------Assert Preconditions --------------
            Assert.IsFalse(editableGridControl.Buttons.Enabled);
            Assert.IsFalse(editableGridControl.FilterControl.Enabled);
            Assert.AreEqual(0, editableGridControl.Grid.Rows.Count);
            Assert.IsFalse(editableGridControl.Grid.AllowUserToAddRows);
            //---------------Execute Test ----------------------
            editableGridControl.SetBusinessObjectCollection(col);
            //---------------Verify Result ---------------------
            Assert.IsTrue(editableGridControl.Buttons.Enabled);
            Assert.IsTrue(editableGridControl.FilterControl.Enabled);
            Assert.AreEqual(5, editableGridControl.Grid.Rows.Count);
            Assert.IsTrue(editableGridControl.Grid.AllowUserToAddRows);
        }
        public void TestSetupColumnAsCheckBoxType_FromClassDef()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef        = MyBO.LoadClassDefWith_Grid_1CheckBoxColumn();
            IEditableGridControl gridControl     = GetControlFactory().CreateEditableGridControl();
            GridInitialiser      gridInitialiser = new GridInitialiser(gridControl, GetControlFactory());

            //--------------Assert PreConditions----------------
            Assert.AreEqual(0, gridControl.Grid.Columns.Count);
            Assert.AreEqual(1, classDef.UIDefCol.Count);
            const string uiDefName = "default";
            IUIGrid      uiGridDef = classDef.UIDefCol[uiDefName].UIGrid;

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

            //---------------Execute Test ----------------------
            gridInitialiser.InitialiseGrid(classDef, uiDefName);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, gridControl.Grid.Columns.Count, "Should have ID column and should have checkBoxColumn");
            IDataGridViewColumn dataGridViewColumn = gridControl.Grid.Columns[1];

            AssertIsCheckBoxColumnType(dataGridViewColumn);
            //---------------Tear Down -------------------------
        }
        public void Test_SetBusinessObjectCollection_IncorrectClassDef()
        {
            //---------------Set up test pack-------------------
            LoadMyBoDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

            //Gizmox.WebGUI.Forms.Form frm = new Gizmox.WebGUI.Forms.Form();
            //frm.Controls.Add((Gizmox.WebGUI.Forms.Control)readOnlyGridControl);
            AddControlToForm(editableGridControl);
            //---------------Execute Test ----------------------
            editableGridControl.Initialise(Sample.CreateClassDefVWG());
            try
            {
                editableGridControl.SetBusinessObjectCollection(col);
                Assert.Fail(
                    "You cannot call set collection for a collection that has a different class def than is initialised");
                ////---------------Test Result -----------------------
            }
            catch (ArgumentException ex)
            {
                StringAssert.Contains(
                    "You cannot call set collection for a collection that has a different class def than is initialised",
                    ex.Message);
            }
        }
        public void Test_EditInTextbox_ExistingObject()
        {
            //---------------Set up test pack-------------------
            IEditableGridControl grid = GetControlFactory().CreateEditableGridControl();

            AddControlToForm(grid);
            MyBO.LoadDefaultClassDef();
            IClassDef def = ClassDef.ClassDefs[typeof(MyBO)];

            grid.Initialise(def);
            BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>();
            MyBO bo = new MyBO();

            bo.TestProp = "testPropValue";
            col.Add(bo);
            grid.Grid.BusinessObjectCollection = col;
            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, grid.Grid.Rows.Count, "Editable auto adds adding row");

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


            const string testvalue = "new test value";

            grid.Grid.Rows[0].Cells[1].Value = testvalue;
            grid.Grid.Rows[1].Selected       = true;
//            grid.ApplyChangesToBusinessObject();

            //---------------Test Result -----------------------
            Assert.AreEqual(testvalue, bo.TestProp);
        }
예제 #20
0
        protected override IBOColSelectorControl CreateSelector()
        {
            IEditableGridControl readOnlyGridControl = GetControlFactory().CreateEditableGridControl();

            System.Windows.Forms.Form frm = new System.Windows.Forms.Form();
            frm.Controls.Add((System.Windows.Forms.Control)readOnlyGridControl);
            return(GetControlledLifetimeFor(readOnlyGridControl));
        }
        protected override IBOColSelectorControl CreateSelector()
        {
            IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl();

            Gizmox.WebGUI.Forms.Form frm = new Gizmox.WebGUI.Forms.Form();
            frm.Controls.Add((Gizmox.WebGUI.Forms.Control)gridControl);
            return(GetControlledLifetimeFor(gridControl));
        }
        protected IEditableGridControl GetGridWith_5_Rows(out BusinessObjectCollection <MyBO> col)
        {
            LoadMyBoDefaultClassDef();
            col = CreateCollectionWith_4_Objects();
            IEditableGridControl gridControl = CreateEditableGridControl();

            SetupGridColumnsForMyBo(gridControl.Grid);
            gridControl.SetBusinessObjectCollection(col);
            return(GetControlledLifetimeFor(gridControl));
        }
        public void TestLayoutManagerContainsAllMainControls()
        {
            //---------------Set up test pack-------------------

            //---------------Execute Test ----------------------
            IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl();
            IFormHabanero        form        = AddControlToForm(gridControl);

            //---------------Test Result -----------------------
            AssertMainControlsOnForm(form);
        }
        public void TestAcceptance_SearchGridSearchesTheGrid()
        {
            //---------------Set up test pack-------------------
            //Clear all contact people from the DB
            ContactPerson.DeleteAllContactPeople();
            IClassDef classDef = ContactPersonTestBO.LoadDefaultClassDefWithUIDef();

            //Create data in the database with the 5 contact people two with Search in surname
            CreateContactPersonInDB();
            CreateContactPersonInDB();
            CreateContactPersonInDB();
            CreateContactPersonInDB_With_SSSSS_InSurname();
            CreateContactPersonInDB_With_SSSSS_InSurname();
            //Create grid setup for search
            IEditableGridControl gridControl = CreateEditableGridControl();
            ITextBox             txtbox      = gridControl.FilterControl.AddStringFilterTextBox("Surname", "Surname");

            gridControl.Initialise(classDef);
            gridControl.FilterMode = FilterModes.Search;

            //--------------Assert PreConditions----------------
            //No items in the grid
            Assert.AreEqual(1, gridControl.Grid.Rows.Count);

            //---------------Execute Test ----------------------
            //set data in grid to a value that should return 2 people
            const string filterByValue = "SSSSS";

            txtbox.Text = filterByValue;
            //grid.filtercontrols.searchbutton.click
            gridControl.OrderBy = "Surname";
            gridControl.FilterControl.ApplyFilter();

            //---------------Test Result -----------------------
            StringAssert.Contains(filterByValue,
                                  gridControl.FilterControl.GetFilterClause().GetFilterClauseString());
            //verify that there are 2 people in the grid.
            Assert.AreEqual(3, gridControl.Grid.Rows.Count);

            BusinessObjectCollection <ContactPersonTestBO> col = new BusinessObjectCollection <ContactPersonTestBO>();

            col.Load("Surname like %" + filterByValue + "%", "Surname");
            Assert.AreEqual(col.Count + 1, gridControl.Grid.Rows.Count);
            int rowNum = 0;

            foreach (ContactPersonTestBO person in col)
            {
                object rowID = gridControl.Grid.Rows[rowNum++].Cells["HABANERO_OBJECTID"].Value;
                Assert.AreEqual(person.ID.ToString(), rowID.ToString());
            }
            //---------------Tear Down -------------------------
            ContactPerson.DeleteAllContactPeople();
        }
        public void Test_GetBusinessObjectCollection_WhenNull()
        {
            //---------------Set up test pack-------------------
            IEditableGridControl editableGridControl = CreateEditableGridControl();
            //---------------Assert Preconditions --------------
            //---------------Execute Test ----------------------
            IBusinessObjectCollection returnedBusinessObjectCollection =
                editableGridControl.GetBusinessObjectCollection();

            //---------------Test Result -----------------------
            Assert.IsNull(returnedBusinessObjectCollection);
        }
        public void Test_SetBusinessObjectCollection_InitialisesGridIfNotPreviouslyInitialised()
        {
            //---------------Set up test pack-------------------
            LoadMyBoDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IEditableGridControl            editableGridControl = CreateEditableGridControl();

            //---------------Execute Test ----------------------
            editableGridControl.SetBusinessObjectCollection(col);
            ////---------------Test Result -----------------------
            Assert.AreEqual("default", editableGridControl.UiDefName);
            Assert.AreEqual(col.ClassDef, editableGridControl.ClassDef);
        }
        public void Test_CreateButtonsControl()
        {
            //---------------Set up test pack-------------------

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

            //---------------Execute Test ----------------------
            IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl();

            //---------------Test Result -----------------------
            Assert.IsNotNull(gridControl.Buttons);
            Assert.AreEqual(2, gridControl.Buttons.Controls.Count);
        }
        public void Test_CreateFilterControl()
        {
            //---------------Set up test pack-------------------

            //--------------Assert PreConditions----------------

            //---------------Execute Test ----------------------
            IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl();

            //---------------Test Result -----------------------
            Assert.AreEqual(FilterModes.Filter, gridControl.FilterMode);
            Assert.AreEqual(FilterModes.Filter, gridControl.FilterControl.FilterMode);
        }
예제 #29
0
        public void TestConstructor()
        {
            //---------------Set up test pack-------------------
            IEditableGridControl editableGrid = GetControlFactory().CreateEditableGridControl();
            const string         propName     = "asdfa";

            //---------------Execute Test ----------------------
            EditableGridControlMapper mapper = new EditableGridControlMapper(editableGrid, propName, false, GetControlFactory());

            //---------------Test Result -----------------------
            Assert.AreSame(editableGrid, mapper.Control);
            Assert.AreEqual(propName, mapper.PropertyName);
            Assert.IsFalse(editableGrid.Buttons.Visible);
        }
예제 #30
0
        public void Test_BusinessObject_WhenNullInitialValue()
        {
            //---------------Set up test pack-------------------
            IEditableGridControl editableGrid = GetControlFactory().CreateEditableGridControl();

            const string propName            = "Addresses";
            EditableGridControlMapper mapper = new EditableGridControlMapper(editableGrid, propName, false, GetControlFactory());

            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            mapper.BusinessObject = null;
            //---------------Test Result -----------------------
            Assert.IsNull(mapper.BusinessObject);
            Assert.AreSame(null, editableGrid.BusinessObjectCollection);
        }
        ///<summary>
        /// Constrcutor for the <see cref="StaticDataEditorManager"/>
        ///</summary>
        ///<param name="staticDataEditor"></param>
        ///<param name="controlFactory"></param>
        public StaticDataEditorManager(IStaticDataEditor staticDataEditor, IControlFactory controlFactory)
        {
            _staticDataEditor = staticDataEditor;
            this._controlFactory = controlFactory;
            _items = new Dictionary<string, IClassDef>();
            _treeView = _controlFactory.CreateTreeView("TreeView");
            _treeView.Width = 200;
            _gridControl = _controlFactory.CreateEditableGridControl();
            BorderLayoutManager layoutManager = _controlFactory.CreateBorderLayoutManager(_staticDataEditor);
            layoutManager.AddControl(_gridControl, BorderLayoutManager.Position.Centre);
            layoutManager.AddControl(_treeView, BorderLayoutManager.Position.West);
            _treeView.AfterSelect += ((sender, e) => SelectItem(e.Node.Text));
            _treeView.BeforeSelect += _treeView_OnBeforeSelect;
            _gridControl.Enabled = false;
            _gridControl.FilterControl.Visible = false;

        }
 ///<summary>
 /// Constructor for <see cref="EditableGridControlManager"/>
 ///</summary>
 ///<param name="gridControl"></param>
 ///<param name="controlFactory"></param>
 public EditableGridControlManager(IEditableGridControl gridControl, IControlFactory controlFactory)
 {
     GridControl = gridControl;
     _gridInitialiser = new GridInitialiser(gridControl, controlFactory);
 }
 /// <summary>
 /// Constructor for the mapper.
 /// </summary>
 /// <param name="ctl">The IEditableGridControl</param>
 /// <param name="relationshipName">This is the relationship name to use - this relationship must be a multiple relationship and exist on the BusinessObject</param>
 /// <param name="isReadOnly">Whether the editable grid should be read only or not. Ignored</param>
 /// <param name="factory">The control factory to use</param>
 public EditableGridControlMapper(IEditableGridControl ctl, string relationshipName, bool isReadOnly, IControlFactory factory)
     : base(ctl, relationshipName, isReadOnly, factory)
 {
     _editableGrid = ctl;
     _editableGrid.Buttons.Visible = false;
 }