/// <summary> /// Selects an item with the given name in the treeview /// </summary> /// <param name="itemName">The name of the item to select</param> public void SelectItem(string itemName) { IClassDef classDef; if (_items.ContainsKey(itemName)) { classDef = _items[itemName]; } else { _gridControl.Enabled = false; return; } try { _gridControl.Initialise(classDef); var col = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection(classDef, ""); _gridControl.Grid.BusinessObjectCollection = col; _gridControl.Enabled = true; } catch (Exception ex) { GlobalRegistry.UIExceptionNotifier.Notify(ex, "There was a problem loading a collection of " + classDef.ClassName, "Problem loading"); } }
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 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_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); }
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); }
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(); }
/// <summary> /// Updates the value on the control from the corresponding property /// on the represented <see cref="IControlMapper.BusinessObject"/> /// </summary> protected override void InternalUpdateControlValueFromBo() { if (_businessObject != null) { var relationship = _businessObject.Relationships[PropertyName]; _editableGrid.Initialise(relationship.RelatedObjectClassDef); _editableGrid.BusinessObjectCollection = _businessObject.Relationships.GetRelatedCollection(PropertyName); } else { _editableGrid.BusinessObjectCollection = null; } }
public void TestFilterControlIsBuiltFromDef() { //---------------Set up test pack------------------- IClassDef classDef = MyBO.LoadDefaultClassDefWithFilterDef(); IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl(); //---------------Assert PreConditions--------------- //---------------Execute Test ---------------------- gridControl.Initialise(classDef); //---------------Test Result ----------------------- Assert.IsTrue(gridControl.FilterControl.Visible); Assert.AreEqual(FilterModes.Filter, gridControl.FilterControl.FilterMode); Assert.IsNotNull(gridControl.FilterControl.GetChildControl("TestProp")); Assert.IsNotNull(gridControl.FilterControl.GetChildControl("TestProp2")); //---------------Tear Down ------------------------- }
public void Test_SetBusinessObjectCollection_NotInitialiseGrid_IfPreviouslyInitialised() { //Verify that setting the collection for a grid that is already initialised //does not cause it to be reinitialised. //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); IClassDef classDef = LoadMyBoDefaultClassDef(); BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects(); const string alternateUIDefName = "Alternate"; IEditableGridControl editableGridControl = CreateEditableGridControl(); editableGridControl.Initialise(classDef, alternateUIDefName); //---------------Execute Test ---------------------- editableGridControl.SetBusinessObjectCollection(col); ////---------------Test Result ----------------------- Assert.AreEqual(alternateUIDefName, editableGridControl.UiDefName); }
public void TestInitialise() { //---------------Set up test pack------------------- IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl(); MyBO.LoadDefaultClassDef(); IClassDef def = ClassDef.ClassDefs[typeof(MyBO)]; //---------------Execute Test ---------------------- gridControl.Initialise(def); //---------------Test Result ----------------------- Assert.AreEqual(3, gridControl.Grid.Columns.Count); Assert.IsFalse(gridControl.Grid.ReadOnly); Assert.IsTrue(gridControl.Grid.AllowUserToAddRows); Assert.IsTrue(gridControl.Grid.AllowUserToDeleteRows); //---------------Tear Down ------------------------- }
public void Test_Using_EditableDataSetProvider() { //---------------Set up test pack------------------- IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl(); MyBO.LoadDefaultClassDef(); IClassDef def = ClassDef.ClassDefs[typeof(MyBO)]; gridControl.Initialise(def); BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>(); //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- gridControl.Grid.BusinessObjectCollection = col; //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(EditableDataSetProvider), gridControl.Grid.DataSetProvider); //---------------Tear Down ------------------------- }
public void TestVWGInitialise_SelectionEditMode() { //---------------Set up test pack------------------- IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl(); MyBO.LoadDefaultClassDef(); IClassDef def = ClassDef.ClassDefs[typeof(MyBO)]; //---------------Execute Test ---------------------- gridControl.Initialise(def); //---------------Test Result ----------------------- Assert.AreEqual (DataGridViewSelectionMode.RowHeaderSelect, ((DataGridView)gridControl.Grid).SelectionMode); Assert.AreEqual (DataGridViewEditMode.EditOnKeystrokeOrF2, ((DataGridView)gridControl.Grid).EditMode); //---------------Tear Down ------------------------- }
public void TestVWG_CheckBoxUIGridDef_Creates_CheckBoxColumn() { //---------------Set up test pack------------------- IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl(); MyBO.LoadClassDefWithBoolean(); IClassDef def = ClassDef.ClassDefs[typeof(MyBO)]; //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- gridControl.Initialise(def); //---------------Test Result ----------------------- IDataGridViewColumn column = gridControl.Grid.Columns["TestBoolean"]; Assert.IsNotNull(column); Assert.IsInstanceOf(typeof(DataGridViewCheckBoxColumnVWG), column); //---------------Tear Down ------------------------- }
public void Test_SetCollection() { //---------------Set up test pack------------------- IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl(); MyBO.LoadDefaultClassDef(); IClassDef def = ClassDef.ClassDefs[typeof(MyBO)]; gridControl.Initialise(def); BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>(); //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- gridControl.Grid.BusinessObjectCollection = col; //---------------Test Result ----------------------- Assert.IsFalse(gridControl.Grid.ReadOnly); Assert.IsTrue(gridControl.Grid.AllowUserToAddRows); Assert.IsTrue(gridControl.Grid.AllowUserToDeleteRows); Assert.AreEqual(1, gridControl.Grid.Rows.Count); //---------------Tear Down ------------------------- }
public void TestInitialise_CopiesValuesToGrid() { //---------------Set up test pack------------------- IEditableGridControl gridControl = GetControlFactory().CreateEditableGridControl(); MyBO.LoadDefaultClassDef(); IClassDef def = ClassDef.ClassDefs[typeof(MyBO)]; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- const string uiDefName = "Alternate"; gridControl.Initialise(def, uiDefName); //---------------Test Result ----------------------- Assert.AreEqual(2, gridControl.Grid.Columns.Count); Assert.IsFalse(gridControl.Grid.ReadOnly); Assert.IsTrue(gridControl.Grid.AllowUserToAddRows); Assert.IsTrue(gridControl.Grid.AllowUserToDeleteRows); Assert.AreEqual(uiDefName, gridControl.UiDefName); Assert.AreEqual(uiDefName, gridControl.Grid.UiDefName); Assert.AreEqual(def, gridControl.ClassDef); Assert.AreEqual(def, gridControl.Grid.ClassDef); }