Beispiel #1
0
        public void Test_Construct()
        {
            //--------------- Set up test pack ------------------
            IControlFactory     controlFactory   = GetControlFactory();
            ExtendedComboBoxWin extendedComboBox = new ExtendedComboBoxWin(controlFactory);
            string propName = TestUtil.GetRandomString();
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
                extendedComboBox, propName, false, controlFactory);

            //--------------- Test Result -----------------------
            Assert.IsInstanceOf(typeof(IControlMapper), mapper);
            Assert.AreSame(extendedComboBox, mapper.Control);
            Assert.AreEqual(propName, mapper.PropertyName);
            Assert.AreEqual(false, mapper.IsReadOnly);
            Assert.AreEqual(controlFactory, mapper.ControlFactory);
            ExtendedComboBoxMapper lookupComboBoxMapper = mapper;

            Assert.IsNotNull(lookupComboBoxMapper);
//            Assert.AreSame(extendedComboBox.ComboBox, lookupComboBoxMapper.Control);
            Assert.AreSame(extendedComboBox, lookupComboBoxMapper.Control);
            Assert.AreEqual(propName, lookupComboBoxMapper.PropertyName);
            Assert.AreEqual(false, lookupComboBoxMapper.IsReadOnly);
            Assert.AreEqual(controlFactory, lookupComboBoxMapper.ControlFactory);
            Assert.AreEqual(lookupComboBoxMapper.ErrorProvider, mapper.ErrorProvider);
        }
Beispiel #2
0
        public void Test_ItemsShowingInComboBox()
        {
            //--------------- Set up test pack ------------------

            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();

            contactPersonTestBO.Surname   = TestUtil.GetRandomString();
            contactPersonTestBO.FirstName = TestUtil.GetRandomString();
            OrganisationTestBO.LoadDefaultClassDef();
            OrganisationTestBO.CreateSavedOrganisation();
            OrganisationTestBO.CreateSavedOrganisation();

            IControlFactory        controlFactory   = GetControlFactory();
            ExtendedComboBoxWin    extendedComboBox = new ExtendedComboBoxWin(controlFactory);
            const string           propName         = "OrganisationID";
            ExtendedComboBoxMapper mapper           = new ExtendedComboBoxMapper(
                extendedComboBox, propName, true, controlFactory);

            //--------------- Test Preconditions ----------------
            Assert.IsNull(mapper.BusinessObject);
            Assert.IsNull(mapper.BusinessObject);

            //--------------- Execute Test ----------------------
            mapper.BusinessObject = contactPersonTestBO;
            //--------------- Test Result -----------------------
            Assert.AreSame(contactPersonTestBO, mapper.BusinessObject);
            Assert.AreSame(contactPersonTestBO, mapper.BusinessObject);
            Assert.AreEqual(2, mapper.LookupList.Count);
        }
Beispiel #3
0
        private static ExtendedComboBoxMapper CreateExtendedLookupComboBoxMapper(string propertyName)
        {
            IControlFactory        controlFactory   = GetControlFactory();
            ExtendedComboBoxWin    extendedComboBox = new ExtendedComboBoxWin(controlFactory);
            ExtendedComboBoxMapper mapper           = new ExtendedComboBoxMapper(
                extendedComboBox, propertyName, true, controlFactory);

            return(mapper);
        }
Beispiel #4
0
        public void Test_SetBusinessObject_ToNull_OnInternalLookupComboBoxMapper()
        {
            //--------------- Set up test pack ------------------
            ExtendedComboBoxMapper mapper = CreateExtendedLookupComboBoxMapper("Surname");

            //--------------- Test Preconditions ----------------
            Assert.IsNull(mapper.BusinessObject);
            Assert.IsNull(mapper.BusinessObject);
            //--------------- Execute Test ----------------------
            mapper.BusinessObject = null;
            //--------------- Test Result -----------------------
            Assert.AreSame(null, mapper.BusinessObject);
        }
Beispiel #5
0
        public void Test_SetBusinessObject_OnInternalLookupComboBoxMapper()
        {
            //--------------- Set up test pack ------------------
            ExtendedComboBoxMapper mapper = CreateExtendedLookupComboBoxMapper("Surname");

            //--------------- Test Preconditions ----------------
            Assert.IsNull(mapper.BusinessObject);
            Assert.IsNull(mapper.BusinessObject);
            ContactPersonTestBO businessObjectInfo = new ContactPersonTestBO();

            //--------------- Execute Test ----------------------
            mapper.BusinessObject = businessObjectInfo;
            //--------------- Test Result -----------------------
            Assert.AreSame(businessObjectInfo, mapper.BusinessObject);
        }
Beispiel #6
0
        public void Test_SetBusinessObject()
        {
            //--------------- Set up test pack ------------------
            ExtendedComboBoxMapper 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);
        }
Beispiel #7
0
        public void Test_ShowGridAndBOEditorControlWinWithSuperClassDef()
        {
            //--------------- Set up test pack ------------------
            ClassDef.ClassDefs.Clear();
            PersonTestBO.LoadDefaultClassDefWithTestOrganisationBOLookup();
            ContactPersonTestBO.LoadDefaultClassDefWithPersonTestBOSuperClass();
            BusinessObjectCollection <OrganisationTestBO> organisationTestBOs = CreateSavedOrganisationTestBOsCollection();


            IControlFactory        controlFactory   = GetControlFactory();
            ExtendedComboBoxWin    extendedComboBox = new ExtendedComboBoxWin(controlFactory);
            const string           propName         = "OrganisationID";
            ExtendedComboBoxMapper mapper           = new ExtendedComboBoxMapper(
                extendedComboBox, propName, true, controlFactory);

            mapper.BusinessObject = new ContactPersonTestBO();
            // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation();
            //--------------- Test Preconditions ----------------
            Assert.IsNull(mapper.PopupForm);
            //--------------- Execute Test ----------------------
            //extendedComboBox.Button.PerformClick();
            mapper.ShowPopupForm();
            //--------------- Test Result -----------------------
            Assert.IsNotNull(mapper.PopupForm);
            IFormHabanero form = mapper.PopupForm;

            Assert.AreEqual(800, form.Width);
            Assert.AreEqual(600, form.Height);
            Assert.AreEqual(1, form.Controls.Count);
            Assert.AreEqual(DockStyle.Fill, form.Controls[0].Dock);

            Assert.IsInstanceOf(typeof(IBOGridAndEditorControl), form.Controls[0]);
            Assert.IsInstanceOf(typeof(BOGridAndEditorControlWin), form.Controls[0]);
            BOGridAndEditorControlWin andBOGridAndEditorControlWin = (BOGridAndEditorControlWin)form.Controls[0];

            //Assert.AreSame(mapper.BusinessObject, BOGridAndEditorControlWin.BOEditorControlWin.BusinessObject);
            Assert.IsTrue(andBOGridAndEditorControlWin.GridControl.IsInitialised);
            IBusinessObjectCollection collection = andBOGridAndEditorControlWin.GridControl.Grid.BusinessObjectCollection;

            Assert.IsNotNull(collection);
            Assert.AreEqual(organisationTestBOs.Count, collection.Count);
            Assert.AreEqual(organisationTestBOs.Count, mapper.LookupList.Count);
        }
Beispiel #8
0
        public void Test_Construct_ReadOnly()
        {
            //--------------- Set up test pack ------------------
            IControlFactory   controlFactory   = GetControlFactory();
            IExtendedComboBox extendedComboBox = CreateExtendedComboBox();
            string            propName         = TestUtil.GetRandomString();
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
                extendedComboBox, propName, true, controlFactory);

            //--------------- Test Result -----------------------
            Assert.IsInstanceOf(typeof(IControlMapper), mapper);
            Assert.AreEqual(true, mapper.IsReadOnly);
            ExtendedComboBoxMapper lookupComboBoxMapper = mapper;

            Assert.IsNotNull(lookupComboBoxMapper);
            Assert.AreEqual(true, lookupComboBoxMapper.IsReadOnly);
        }