Inheritance: BusinessObject
        public void TestBusinessObjectControlHasDifferentBOWhenTabChanges()
        {
            //---------------Set up test pack-------------------
            IBOColTabControl boColTabControl = GetControlFactory().CreateBOColTabControl();

            IBusinessObjectControl busControl = GetBusinessObjectControlStub();
            boColTabControl.BusinessObjectControl = busControl;

            BusinessObjectCollection<MyBO> myBoCol = new BusinessObjectCollection<MyBO>();
            MyBO firstBo = new MyBO();
            myBoCol.Add(firstBo);
            myBoCol.Add(new MyBO());
            MyBO thirdBO = new MyBO();
            myBoCol.Add(thirdBO);
            boColTabControl.BusinessObjectCollection = myBoCol;

            //---------------Assert Precondition----------------
            Assert.AreEqual(firstBo, boColTabControl.BusinessObjectControl.BusinessObject);

            //---------------Execute Test ----------------------
            boColTabControl.TabControl.SelectedIndex = 2;

            //---------------Test Result -----------------------
            Assert.AreNotSame(firstBo, boColTabControl.BusinessObjectControl.BusinessObject);
            Assert.AreEqual(thirdBO, boColTabControl.BusinessObjectControl.BusinessObject);
        }
        public void Test_BusinessObjectEdited_ShouldRefreshTheValueInTheList()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadDefaultClassDef();
            var listBox = GetControlFactory().CreateListBox();
            var manager = CreateListBoxCollectionManager(listBox);
            var boToBeUpdated = new MyBO();
            var myBoCol = new BusinessObjectCollection<MyBO> {new MyBO(), boToBeUpdated };
            manager.BusinessObjectCollection = myBoCol;

            manager.Control.SelectedItem = boToBeUpdated;
            var initialListBoxDisplayText = manager.Control.Text;
            var initialBOToString = boToBeUpdated.ToString();
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, manager.Control.Items.Count);

            Assert.AreSame(boToBeUpdated, manager.Control.Items[1]);
            Assert.AreEqual(initialBOToString, initialListBoxDisplayText);
            //---------------Execute Test ----------------------
            boToBeUpdated.TestProp = GetRandomString();
            boToBeUpdated.Save();
            //---------------Test Result -----------------------
            var updatedListBoxDisplayText = manager.Control.Text;
            var updatedBOToString = boToBeUpdated.ToString();
            Assert.AreNotEqual(initialListBoxDisplayText, updatedListBoxDisplayText);
            Assert.AreNotEqual(initialBOToString, updatedBOToString);

            Assert.AreEqual(updatedBOToString, updatedListBoxDisplayText);
        }
        public void Test_ControlMapperStrategy_AddBOPropHandlers()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadDefaultClassDef();
            var strategyWin = new ControlMapperStrategyWin();
            var factory = new Habanero.Faces.Win.ControlFactoryWin();
            var tb = factory.CreateTextBox();
            const string testprop = "TestProp";
            var stubMapper = new ControlMapperStub(tb, testprop, false, factory);
            var bo = new MyBO();
            var prop = bo.Props[testprop];
            const string origvalue = "origValue";
            prop.Value = origvalue;
            stubMapper.BusinessObject = bo;
            strategyWin.RemoveCurrentBOPropHandlers(stubMapper, prop);

            //--------------Assert PreConditions----------------            
            Assert.AreEqual(origvalue, tb.Text);

            //---------------Execute Test ----------------------
            strategyWin.AddCurrentBOPropHandlers(stubMapper, prop);
            const string newValue = "New value";
            prop.Value = newValue;

            //---------------Test Result -----------------------
            Assert.AreEqual(newValue, tb.Text);

        }
 protected virtual IBusinessObjectCollection GetCollectionWith_4_Objects()
 {
     MyBO cp = new MyBO { TestProp = "b" };
     MyBO cp2 = new MyBO { TestProp = "d" };
     MyBO cp3 = new MyBO { TestProp = "c" };
     MyBO cp4 = new MyBO { TestProp = "a" };
     return new BusinessObjectCollection<MyBO> { cp, cp2, cp3, cp4 };
 }
Exemplo n.º 5
0
 protected void SetupClassDefs(object propValue)
 {
     ClassDef.ClassDefs.Clear();
     IClassDef itsClassDef = MyBO.LoadClassDefWithRelationship();
     IClassDef itsRelatedClassDef = MyRelatedBo.LoadClassDef();
     itsMyBo = (MyBO)itsClassDef.CreateNewBusinessObject();
     MyRelatedBo relatedBo = (MyRelatedBo)itsRelatedClassDef.CreateNewBusinessObject();
     Guid myRelatedBoGuid = relatedBo.ID.GetAsGuid();
     itsMyBo.SetPropertyValue("RelatedID", myRelatedBoGuid);
     relatedBo.SetPropertyValue("MyRelatedTestProp", propValue);
     itsMyBo.Save();
     relatedBo.Save();
 }
 public override void Test_SelectedBusinessObject_ReturnsNullIfNoItemSelected()
 {
     //---------------Set up test pack-------------------
     IBOColSelectorControl colSelector = CreateSelector();
     MyBO myBO = new MyBO();
     BusinessObjectCollection<MyBO> collection = new BusinessObjectCollection<MyBO> { myBO };
     colSelector.BusinessObjectCollection = collection;
     colSelector.SelectedBusinessObject = null;
     //---------------Assert Precondition----------------
     Assert.AreEqual(collection.Count + NumberOfLeadingBlankRows(), colSelector.NoOfItems, "The blank item and one other");
     //---------------Execute Test ----------------------
     IBusinessObject selectedBusinessObject = colSelector.SelectedBusinessObject;
     //---------------Test Result -----------------------
     Assert.IsNull(selectedBusinessObject);
 }
 public override void Test_Set_SelectedBusinessObject_Null_SetsItemNull()
 {
     //---------------Set up test pack-------------------
     IBOColSelectorControl colSelector = CreateSelector();
     MyBO myBO = new MyBO();
     MyBO myBO2 = new MyBO();
     BusinessObjectCollection<MyBO> collection = new BusinessObjectCollection<MyBO> { myBO, myBO2 };
     colSelector.BusinessObjectCollection = collection;
     SetSelectedIndex(colSelector, ActualIndex(1));
     //---------------Assert Precondition----------------
     Assert.AreEqual(collection.Count + NumberOfLeadingBlankRows(), colSelector.NoOfItems, "The blank item and others");
     Assert.AreEqual(ActualIndex(1), SelectedIndex(colSelector));
     Assert.AreEqual(myBO2, colSelector.SelectedBusinessObject);
     //---------------Execute Test ----------------------
     colSelector.SelectedBusinessObject = null;
     //---------------Test Result -----------------------
     Assert.IsNull(colSelector.SelectedBusinessObject);
     Assert.AreEqual(-1, SelectedIndex(colSelector));
 }
 public override void Test_RemoveBOToCol_UpdatesItems()
 {
     //---------------Set up test pack-------------------
     IBOColSelectorControl colSelector = CreateSelector();
     MyBO myBO = new MyBO();
     MyBO newMyBO = new MyBO();
     BusinessObjectCollection<MyBO> collection = new BusinessObjectCollection<MyBO> {myBO, newMyBO};
     colSelector.BusinessObjectCollection = collection;
     //---------------Assert Precondition----------------
     Assert.AreEqual
         (collection.Count + NumberOfLeadingBlankRows(), colSelector.NoOfItems, "The blank item and one other");
     Assert.AreSame(myBO, colSelector.GetBusinessObjectAtRow(ActualIndex(0)));
     Assert.AreSame(newMyBO, colSelector.GetBusinessObjectAtRow(ActualIndex(1)));
     //---------------Execute Test ----------------------
     collection.Remove(myBO);
     //---------------Test Result -----------------------
     Assert.AreEqual(ActualNumberOfRows(1), colSelector.NoOfItems, "The blank item and one other");
     Assert.AreSame(newMyBO, colSelector.GetBusinessObjectAtRow(ActualIndex(0)));
 }
        public void TestChangeControlValues_DoesNotChangeBusinessObjectValues()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();
            myBO.TestProp = START_VALUE_1;
            myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2);

            Habanero.Faces.Base.PanelBuilder factory = new Habanero.Faces.Base.PanelBuilder(GetControlFactory());
            IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);
            panelInfo.BusinessObject = myBO;
            //---------------Execute Test ----------------------
            ChangeValuesInControls(panelInfo);
            //---------------Test Result -----------------------

            Assert.AreEqual(START_VALUE_1, myBO.GetPropertyValue(TEST_PROP_1));
            Assert.AreEqual(START_VALUE_2, myBO.GetPropertyValue(TEST_PROP_2));

        }
        public void TestCreateTestListBoxCollectionController()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadClassDefWithBoolean();
            BusinessObjectCollection<MyBO> myBOs = new BusinessObjectCollection<MyBO>();
            MyBO myBO1 = new MyBO();
            MyBO myBO2 = new MyBO();
            myBOs.Add(myBO1, myBO2);
            IListBox cmb = CreateListBox();
            var selector = CreateListBoxCollectionManager(cmb);
            //---------------Verify test pack-------------------
            //---------------Execute Test ----------------------

            selector.SetCollection(myBOs);
            //---------------Verify Result -----------------------
            Assert.AreEqual(myBOs, selector.Collection);
            Assert.AreSame(cmb, selector.Control);
            //---------------Tear Down -------------------------   
        }
        public void Test_BusinessObjectEdited_WhenMultiSelected_ShouldRemainMultiSelected()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadDefaultClassDef();
            var listBox = GetControlFactory().CreateListBox();
            var manager = CreateListBoxCollectionManager(listBox);
            var boToBeUpdated = new MyBO();
            var myBoCol = new BusinessObjectCollection<MyBO> {new MyBO(), boToBeUpdated };
            manager.BusinessObjectCollection = myBoCol;

            manager.Control.SetSelected(1, true);
            //---------------Assert Precondition----------------
            Assert.IsTrue(manager.Control.SelectedItems.Contains(boToBeUpdated));
            //---------------Execute Test ----------------------
            boToBeUpdated.TestProp = GetRandomString();
            boToBeUpdated.Save();
            //---------------Test Result -----------------------
            Assert.IsTrue(manager.Control.SelectedItems.Contains(boToBeUpdated), "Should still be multi selected");

        }
Exemplo n.º 12
0
 public void TestCreateBOEditorForm_BoParam_UiDefNameParam_GroupControlCreator()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadDefaultClassDef();
     MyBO businessObject = new MyBO();
     const string uiDefName = "Alternate";
     GroupControlCreator controlCreator = GetControlFactory().CreateTabControl;
     //---------------Verify test pack-------------------
     //---------------Execute Test ----------------------
     IDefaultBOEditorForm boEditorForm = _factory.CreateBOEditorForm(businessObject, uiDefName, controlCreator);
     DisposeOnTearDown(boEditorForm);
     //---------------Verify Result -----------------------
     Assert.IsNotNull(boEditorForm);
     Assert.AreSame(businessObject, boEditorForm.PanelInfo.BusinessObject);
     Assert.AreEqual(uiDefName, boEditorForm.PanelInfo.UIForm.UIDef.Name);
     Assert.AreSame(controlCreator, boEditorForm.GroupControlCreator);
 }
Exemplo n.º 13
0
 public void TestCreateBOEditorForm_BoParam_UiDefNameParam_PostObjectPersistingParam()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadDefaultClassDef();
     MyBO businessObject = new MyBO();
     const string uiDefName = "Alternate";
     PostObjectEditDelegate action = delegate {  };
     //---------------Verify test pack-------------------
     //---------------Execute Test ----------------------
     IDefaultBOEditorForm boEditorForm = _factory.CreateBOEditorForm(businessObject, uiDefName, action);
     DisposeOnTearDown(boEditorForm);
     //---------------Verify Result -----------------------
     Assert.IsNotNull(boEditorForm);
     Assert.AreSame(businessObject, boEditorForm.PanelInfo.BusinessObject);
     Assert.AreEqual(uiDefName, boEditorForm.PanelInfo.UIForm.UIDef.Name);
 }
Exemplo n.º 14
0
 public void TestCreateBOEditorForm_BoParam()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadDefaultClassDef();
     MyBO businessObject = new MyBO();
     //---------------Verify test pack-------------------
     //---------------Execute Test ----------------------
     IDefaultBOEditorForm boEditorForm = _factory.CreateBOEditorForm(businessObject);
     DisposeOnTearDown(boEditorForm);
     //---------------Verify Result -----------------------
     Assert.IsNotNull(boEditorForm);
     Assert.AreSame(businessObject, boEditorForm.PanelInfo.BusinessObject);
 }
 public void Test_BusinessObjectAddedToCollection()
 {
     var cmbox = GetControlFactory().CreateComboBox();
     DisposeOnTearDown(cmbox);
     var controlFactory = GetControlFactory();
     var selectorManager = new ComboBoxCollectionSelector(cmbox, controlFactory)
                                                      {IncludeBlankItem = false};
     DisposeOnTearDown(selectorManager);
     MyBO.LoadDefaultClassDef();
     var addedBo = new MyBO();
     var myBoCol = new BusinessObjectCollection<MyBO>
                                                  {new MyBO(), new MyBO(), new MyBO()};
     selectorManager.SetCollection(myBoCol);
     //---------------Execute Test ----------------------
     selectorManager.BusinessObjectCollection.Add(addedBo);
     //---------------Test Result -----------------------
     Assert.AreEqual(4, selectorManager.Control.Items.Count);
     //---------------Tear down -------------------------
 }
        public virtual void TestRejectChanges()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            IClassDef classDef1 = MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();
            string originalValue = TestUtil.GetRandomString();
            myBO.TestProp = originalValue;
            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);

            //---------------Execute Test ----------------------
            gridControl.Grid.SelectedBusinessObject = myBO;
            string newValue = TestUtil.GetRandomString();
            gridControl.Grid.CurrentRow.Cells["TestProp"].Value = newValue;
            bool result = editor.RejectChanges();
            //---------------Test Result -----------------------
            Assert.IsTrue(result);
            BusinessObjectCollection<MyBO> collection = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection<MyBO>("");
            Assert.AreEqual(1, collection.Count);
            Assert.AreEqual(originalValue, myBO.TestProp);
            Assert.IsFalse(myBO.Status.IsDirty);
            //---------------Tear Down -------------------------
            TearDownForm(frm);
        }
 public void Test_SetComboBoxCollection_IncludeBlank_True()
 {
     //---------------Set up test pack-------------------
     var cmbox = GetControlFactory().CreateComboBox();
     DisposeOnTearDown(cmbox);
     var controlFactory = GetControlFactory();
     var selectorManager = new ComboBoxCollectionSelector(cmbox, controlFactory);
     DisposeOnTearDown(selectorManager);
     MyBO.LoadDefaultClassDef();
     var firstBo = new MyBO();
     var myBoCol = new BusinessObjectCollection<MyBO>
                                                  {firstBo, new MyBO(), new MyBO()};
     //---------------Execute Test ----------------------
     selectorManager.SetCollection(myBoCol);
     //---------------Test Result -----------------------
     Assert.AreSame(firstBo, selectorManager.SelectedBusinessObject);
     Assert.AreEqual(4, cmbox.Items.Count);
 }
        public override void Test_Set_SelectedBusinessObject_ItemNotInList_SetsItemNull()
        {
            //---------------Set up test pack-------------------
            IBOColSelectorControl colSelector = CreateSelector();
            MyBO myBO = new MyBO();
            MyBO myBO2 = new MyBO();
            BusinessObjectCollection<MyBO> collection = new BusinessObjectCollection<MyBO> {myBO, myBO2};
            colSelector.BusinessObjectCollection = collection;
//            SetSelectedIndex(selector, ActualIndex(1));
            colSelector.SelectedBusinessObject = myBO2;
            //---------------Assert Precondition----------------
            Assert.AreEqual
                (collection.Count + NumberOfLeadingBlankRows(), colSelector.NoOfItems, "The blank item and others");
            Assert.AreEqual(ActualIndex(1), SelectedIndex(colSelector));
            Assert.AreEqual(myBO2, colSelector.SelectedBusinessObject);
            //---------------Execute Test ----------------------
            colSelector.SelectedBusinessObject = new MyBO();
            //---------------Test Result -----------------------
            Assert.AreEqual(ActualIndex(2), colSelector.NoOfItems, "The blank item");
            Assert.IsNull(colSelector.SelectedBusinessObject);
            Assert.AreEqual
                (1, SelectedIndex(colSelector),
                 "This does not make sense with a collapsible panel similar to a boTabcontrol");
        }
        public void TestInitGrid_UIDef_CurrencyFormat_WhenVirtualProp_ShouldFormatColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWithCurrencyParameterFormat();
            IReadOnlyGridControl grid = CreateReadOnlyGridControl();
            IGridInitialiser initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef uiDef = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;
            AddControlToForm(grid);

            //--------------Assert PreConditions----------------            
            const string formattedPropertyName = "TestCurrencyFormat";
            Assert.IsNotNull(uiGridDef[formattedPropertyName]);
            Assert.IsNotNull(uiGridDef[formattedPropertyName].GetParameterValue("currencyFormat"));

            const string unformattedPropName = "TestCurrencyNoFormat";
            Assert.IsNotNull(uiGridDef[unformattedPropName]);
            Assert.IsNull(uiGridDef[unformattedPropName].GetParameterValue("currencyFormat"));

            object currencyFormat = uiGridDef[formattedPropertyName].GetParameterValue("currencyFormat");
            string currencyFormatParameter = currencyFormat.ToString();
            const string expectedFormat = "### ###.##";
            Assert.AreEqual(expectedFormat, currencyFormatParameter);

            MyBO myBo = new MyBO();
            const double currencyValue = 222222.55555d;
            myBo.SetPropertyValue(formattedPropertyName, currencyValue);
            BusinessObjectCollection<MyBO> col = new BusinessObjectCollection<MyBO>();
            col.Add(myBo);

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            grid.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[formattedPropertyName];
            //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false;
            Assert.AreSame(typeof(Double), dataGridViewCell.ValueType);
            Assert.AreEqual(currencyValue.ToString(expectedFormat), dataGridViewCell.FormattedValue);
        }
Exemplo n.º 20
0
 private static BusinessObjectCollection<MyBO> CreateCollectionWith_4_Objects()
 {
     MyBO cp = new MyBO {TestProp = "b"};
     MyBO cp2 = new MyBO {TestProp = "d"};
     MyBO cp3 = new MyBO {TestProp = "c"};
     MyBO cp4 = new MyBO {TestProp = "a"};
     BusinessObjectCollection<MyBO> col = new BusinessObjectCollection<MyBO> {{cp, cp2, cp3, cp4}};
     return col;
 }
 public void Test_SelectedBusinessObject_EdgeCase_SelectCustomStringItem_ShouldReturnNull()
 {
     //---------------Set up test pack-------------------
     IComboBox cmbox = GetControlFactory().CreateComboBox();
     DisposeOnTearDown(cmbox);
     IControlFactory controlFactory = GetControlFactory();
     var selectorManager = new ComboBoxCollectionSelector(cmbox, controlFactory);
     DisposeOnTearDown(selectorManager);
     selectorManager.IncludeBlankItem = false;
     MyBO.LoadDefaultClassDef();
     MyBO selectedBO = new MyBO();
     BusinessObjectCollection<MyBO> myBoCol = new BusinessObjectCollection<MyBO> { new MyBO(), selectedBO, new MyBO() };
     selectorManager.IncludeBlankItem = false;
     selectorManager.SetCollection(myBoCol);
     selectorManager.Control.SelectedIndex = 1;
     cmbox.Items.Add("SomeItem");
     //---------------Assert Preconditions---------------
     Assert.AreEqual(selectedBO, selectorManager.SelectedBusinessObject);
     //---------------Execute Test ----------------------
     cmbox.SelectedIndex = cmbox.Items.Count - 1;
     IBusinessObject selectedBusinessObject = selectorManager.SelectedBusinessObject;
     //---------------Test Result -----------------------
     Assert.IsNull(selectedBusinessObject);
 }
 public void Test_BusinessObjectRemovedFromCollection()
 {
     IComboBox cmbox = GetControlFactory().CreateComboBox();
     DisposeOnTearDown(cmbox);
     IControlFactory controlFactory = GetControlFactory();
     ComboBoxCollectionSelector selectorManager = new ComboBoxCollectionSelector(cmbox, controlFactory)
                                                      {IncludeBlankItem = false};
     DisposeOnTearDown(selectorManager);
     MyBO.LoadDefaultClassDef();
     MyBO removedBo = new MyBO();
     BusinessObjectCollection<MyBO> myBoCol = new BusinessObjectCollection<MyBO>
                                                  {new MyBO(), removedBo, new MyBO()};
     selectorManager.SetCollection(myBoCol);
     //---------------Execute Test ----------------------
     selectorManager.BusinessObjectCollection.Remove(removedBo);
     //---------------Test Result -----------------------
     Assert.AreEqual(2, selectorManager.Control.Items.Count);
 }
 private static MyBO CreateSavedMyBo()
 {
     MyBO myBO = new MyBO();
     myBO.TestProp = BOTestUtils.RandomString;
     myBO.Save();
     return myBO;
 }
Exemplo n.º 24
0
 public void GridLoaderDelegateStub(IGridBase grid, IBusinessObjectCollection col)
 {
     MyBO cp = new MyBO();
     cp.TestProp = "b";
     grid.Rows.Add(cp.ID,cp.TestProp);
 }
 private static void AssertSelectedBusinessObject(MyBO myBO, IGridWithPanelControl<MyBO> gridWithPanelControl)
 {
     Assert.AreSame(myBO, gridWithPanelControl.ReadOnlyGridControl.SelectedBusinessObject);
     Assert.AreSame(myBO, gridWithPanelControl.BusinessObjectControl.BusinessObject, "Selected BO in Grid should be loaded in the BoControl");
     Assert.AreSame(myBO, gridWithPanelControl.CurrentBusinessObject);
 }
Exemplo n.º 26
0
 public override void Test_SetBOCollection_WhenAutoSelectsFirstItem_ShouldSelectFirstItem()
 {
     //---------------Set up test pack-------------------
     IBOColSelectorControl colSelector = CreateSelector();
     MyBO myBO = new MyBO();
     MyBO myBO2 = new MyBO();
     BusinessObjectCollection<MyBO> collection = new BusinessObjectCollection<MyBO> { myBO, myBO2 };
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, colSelector.NoOfItems);
     Assert.AreEqual(-1, SelectedIndex(colSelector));
     Assert.AreEqual(null, colSelector.SelectedBusinessObject);
     //---------------Execute Test ----------------------
     colSelector.BusinessObjectCollection = collection;
     //---------------Test Result -----------------------
     Assert.AreEqual(collection.Count + NumberOfLeadingBlankRows(), colSelector.NoOfItems, "The blank item");
     Assert.AreSame(myBO, colSelector.SelectedBusinessObject);
     Assert.AreEqual(ActualIndex(0), SelectedIndex(colSelector));
 }
 public void Test_SetBusinessObject()
 {
     //--------------- Set up test pack ------------------
     ExtendedTextBoxMapper mapper = CreateExtendedLookupComboBoxMapper("TestProp");
     //--------------- Test Preconditions ----------------
     Assert.IsNull(mapper.BusinessObject);
     Assert.IsNull(mapper.BusinessObject);
     MyBO.LoadClassDefWithBOLookup();
     MyBO myBO = new MyBO();
     //--------------- Execute Test ----------------------
     mapper.BusinessObject = myBO;
     //--------------- Test Result -----------------------
     Assert.AreSame(myBO, mapper.BusinessObject);
     Assert.AreSame(myBO, mapper.BusinessObject);
 }
 public void Test_SelectedBusinessObject()
 {
     //---------------Set up test pack-------------------
     var cmbox = GetControlFactory().CreateComboBox();
     DisposeOnTearDown(cmbox);
     var controlFactory = GetControlFactory();
     var selectorManager = new ComboBoxCollectionSelector(cmbox, controlFactory)
                                                      {IncludeBlankItem = false};
     DisposeOnTearDown(selectorManager);
     MyBO.LoadDefaultClassDef();
     var selectedBO = new MyBO();
     var myBoCol = new BusinessObjectCollection<MyBO>
                                                  {new MyBO(), selectedBO, new MyBO()};
     //---------------Execute Test ----------------------
     selectorManager.SetCollection(myBoCol);
     selectorManager.Control.SelectedIndex = 1;
     //---------------Test Result -----------------------
     Assert.AreEqual(selectedBO, selectorManager.SelectedBusinessObject);
     //---------------Tear down -------------------------
 }
        public void TestInitGrid_GlobalDateFormat_FormatsDateColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWithDateTimeParameterFormat();
            IReadOnlyGridControl grid = CreateReadOnlyGridControl();
            IGridInitialiser initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef uiDef = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;
            AddControlToForm(grid);
            const string dateTimeNoFormatPropertyName = "TestDateTimeNoFormat";

            const string expectedFormat = "dd.MMM.yyyy";
            GlobalUIRegistry.DateDisplaySettings = new DateDisplaySettings();
            GlobalUIRegistry.DateDisplaySettings.GridDateFormat = expectedFormat;
            //--------------Assert PreConditions----------------            
            IUIGridColumn dateTimeNoFormatGridColumn = uiGridDef[dateTimeNoFormatPropertyName];
            Assert.IsNotNull(dateTimeNoFormatGridColumn);
            Assert.IsNull(dateTimeNoFormatGridColumn.GetParameterValue("dateFormat"));
            Assert.IsNotNull(GlobalUIRegistry.DateDisplaySettings);
            Assert.AreEqual(expectedFormat, GlobalUIRegistry.DateDisplaySettings.GridDateFormat);

            MyBO myBo = new MyBO();
            DateTime currentDateTime = DateTime.Now;
            myBo.SetPropertyValue(dateTimeNoFormatPropertyName, currentDateTime);
            BusinessObjectCollection<MyBO> col = new BusinessObjectCollection<MyBO>();
            col.Add(myBo);

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            grid.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[dateTimeNoFormatPropertyName];
            //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false;
            Assert.AreSame(typeof(DateTime), dataGridViewCell.ValueType);
            Assert.AreEqual(currentDateTime.ToString(expectedFormat), dataGridViewCell.FormattedValue);

            //---------------Tear Down -------------------------          
        }
        public void TestGetTabPage()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            ITabControl tabControl = GetControlFactory().CreateTabControl();
            BOColTabControlManager colTabCtlMapper = new BOColTabControlManager(tabControl, GetControlFactory());
            IBusinessObjectControl busControl = this.CreateBusinessObjectControl();
            colTabCtlMapper.BusinessObjectControl = busControl;
            //---------------Execute Test ----------------------
            BusinessObjectCollection<MyBO> myBoCol = new BusinessObjectCollection<MyBO>();
            MyBO testBo = new MyBO();
            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            myBoCol.Add(testBo);
            colTabCtlMapper.BusinessObjectCollection = myBoCol;
            //---------------Test Result -----------------------
            Assert.AreSame(colTabCtlMapper.TabControl.TabPages[2], colTabCtlMapper.GetTabPage(testBo));
            //---------------Tear down -------------------------
        }