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); }
public void TestAddItem() { //---------------Set up test pack------------------- IClassDef classDef = MyBO.LoadDefaultClassDef(); IFormHabanero frm; IStaticDataEditor editor = CreateEditorOnForm(out frm); ITreeView treeView = (ITreeView)editor.Controls[1]; editor.AddSection(TestUtil.GetRandomString()); string itemName = TestUtil.GetRandomString(); //---------------Assert Preconditions--------------- Assert.AreEqual(1, treeView.Nodes.Count); //---------------Execute Test ---------------------- editor.AddItem(itemName, classDef); //---------------Test Result ----------------------- Assert.AreEqual(1, treeView.Nodes.Count); ITreeNode topNode = treeView.Nodes[0]; Assert.AreEqual(1, topNode.Nodes.Count); Assert.AreEqual(itemName, topNode.Nodes[0].Text); Assert.AreEqual(treeView.TopNode.Text, topNode.Nodes[0].Parent.Text); //---------------Tear Down ------------------------- TearDownForm(frm); }
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); }
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); }
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); }
public void TestAddSecondSection() { //---------------Set up test pack------------------- IFormHabanero frm; IStaticDataEditor editor = CreateEditorOnForm(out frm); ITreeView treeView = (ITreeView)editor.Controls[1]; editor.AddSection(TestUtil.GetRandomString()); string sectionName = TestUtil.GetRandomString(); //---------------Assert Preconditions--------------- Assert.AreEqual(1, treeView.Nodes.Count); //---------------Execute Test ---------------------- editor.AddSection(sectionName); //---------------Test Result ----------------------- Assert.AreEqual(2, treeView.Nodes.Count); Assert.AreEqual(sectionName, treeView.Nodes[1].Text); Assert.AreEqual(treeView.TopNode.Text, treeView.Nodes[0].Text); Assert.AreNotEqual(sectionName, treeView.TopNode.Text); //---------------Tear Down ------------------------- TearDownForm(frm); }
protected override IStaticDataEditor CreateEditorOnForm(out IFormHabanero frm) { frm = GetControlFactory().CreateForm(); IStaticDataEditor editor = GetControlFactory().CreateStaticDataEditor(); frm.Controls.Add(editor); frm.Show(); return(editor); }
///<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> /// 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; }
public void TestLayoutOfEditor() { //---------------Set up test pack------------------- IFormHabanero frm; //---------------Execute Test ---------------------- IStaticDataEditor editor = CreateEditorOnForm(out frm); //---------------Test Result ----------------------- Assert.AreEqual(2, editor.Controls.Count); Assert.IsInstanceOf(typeof(IEditableGridControl), editor.Controls[0]); Assert.IsInstanceOf(typeof(ITreeView), editor.Controls[1]); IEditableGridControl editableGridControl = (IEditableGridControl)editor.Controls[0]; Assert.AreEqual(DockStyle.Fill, editor.Controls[0].Dock); Assert.AreEqual(DockStyle.Left, editor.Controls[1].Dock); Assert.IsFalse(editableGridControl.FilterControl.Visible); //---------------Tear down ------------------------- TearDownForm(frm); }