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

            //--------------- Execute Test ----------------------
            ExtendedTextBoxMapper mapper = new ExtendedTextBoxMapper(
                extendedTextBoxVWG, propName, false, controlFactory);

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

            Assert.IsNotNull(lookupComboBoxMapper);
            Assert.AreSame(extendedTextBoxVWG, lookupComboBoxMapper.Control);
            Assert.AreEqual(propName, lookupComboBoxMapper.PropertyName);
            Assert.AreEqual(false, lookupComboBoxMapper.IsReadOnly);
            Assert.AreEqual(controlFactory, lookupComboBoxMapper.ControlFactory);
            Assert.AreEqual(lookupComboBoxMapper.ErrorProvider, mapper.ErrorProvider);
        }
Exemple #2
0
        public void Test_SelectButtonWhenClicked_ShouldApplyBusinessObjectChanges()
        {
            //---------------Set up test pack-------------------
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxVWG       extendedTextBoxVWG = new ExtendedTextBoxVWG(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapperSpy          = new ExtendedTextBoxMapperSpy(
                extendedTextBoxVWG, propName, true, controlFactory);
            ContactPersonTestBO contactPersonTestBo = new ContactPersonTestBO();

            mapperSpy.BusinessObject = contactPersonTestBo;
            var expectedSelectedBO = new OrganisationTestBO();

            //---------------Assert Precondition----------------
            Assert.AreSame(contactPersonTestBo, mapperSpy.BusinessObject);
            Assert.IsNull(contactPersonTestBo.OrganisationID);
            //---------------Execute Test ----------------------
            mapperSpy.CallSetupPopupForm();
            mapperSpy.SetSelectedBusinessObject(expectedSelectedBO);
            mapperSpy.CallSelectClick();
            //---------------Test Result -----------------------
            Assert.IsNotNull(contactPersonTestBo.OrganisationID);
            Assert.AreSame(expectedSelectedBO, contactPersonTestBo.Organisation);
        }
Exemple #3
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();
            ExtendedTextBoxVWG    extendedTextBoxVWG = new ExtendedTextBoxVWG(controlFactory);
            const string          propName           = "OrganisationID";
            ExtendedTextBoxMapper mapper             = new ExtendedTextBoxMapper(
                extendedTextBoxVWG, 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);
        }
Exemple #4
0
        private static ExtendedTextBoxMapper CreateExtendedLookupComboBoxMapper(string propertyName)
        {
            IControlFactory       controlFactory     = GetControlFactory();
            ExtendedTextBoxVWG    extendedTextBoxVWG = new ExtendedTextBoxVWG(controlFactory);
            ExtendedTextBoxMapper mapper             = new ExtendedTextBoxMapper(
                extendedTextBoxVWG, propertyName, true, controlFactory);

            return(mapper);
        }
Exemple #5
0
        public void Test_SetupPopupForm_WithSuperClassDef_ShouldSetUpThePopUpForm()
        {
            //--------------- Set up test pack ------------------
            BusinessObjectCollection <OrganisationTestBO> organisationTestBOs = GetClassDefs();

            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxVWG       extendedTextBoxVWG = new ExtendedTextBoxVWG(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapper             = new ExtendedTextBoxMapperSpy(
                extendedTextBoxVWG, propName, true, controlFactory);

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

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

            Assert.IsInstanceOf(typeof(IBOGridAndEditorControl), form.Controls[0]);
            Assert.IsInstanceOf(typeof(BOGridAndEditorControlVWG), form.Controls[0]);
            Assert.IsInstanceOf <IButtonGroupControl>(form.Controls[1]);

            IButtonGroupControl control = (IButtonGroupControl)form.Controls[1];

            Assert.AreEqual("Cancel", control.Controls[0].Text);
            Assert.AreEqual("Select", control.Controls[1].Text);

            BOGridAndEditorControlVWG andBOGridAndEditorControlVWG = (BOGridAndEditorControlVWG)form.Controls[0];

            //Assert.AreSame(mapper.BusinessObject, BOGridAndEditorControlVWG.BOEditorControlVWG.BusinessObject);
            Assert.IsTrue(andBOGridAndEditorControlVWG.GridControl.IsInitialised);
            IBusinessObjectCollection collection = andBOGridAndEditorControlVWG.GridControl.Grid.BusinessObjectCollection;

            Assert.IsNotNull(collection);
            Assert.AreEqual(organisationTestBOs.Count, collection.Count);
            //            Assert.AreEqual(organisationTestBOs.Count, mapper.LookupList.Count);
        }
Exemple #6
0
        public void Test_CancelButton_WhenClicked_ShouldCancelEditsAndCloseForm()
        {
            //---------------Set up test pack-------------------
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxVWG       extendedTextBoxVWG = new ExtendedTextBoxVWG(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapper             = new ExtendedTextBoxMapperSpy(
                extendedTextBoxVWG, propName, true, controlFactory);

            mapper.BusinessObject = new ContactPersonTestBO();
            mapper.CallSetupPopupForm();
            //---------------Assert Precondition----------------
            Assert.IsFalse(mapper.FormClosed);
            //---------------Execute Test ----------------------
            mapper.CallCancelClick();
            //---------------Test Result -----------------------
            Assert.IsTrue(mapper.FormClosed);
        }
Exemple #7
0
        public void Test_SelectButtonWhenClicked_ShouldClosePopupForm()
        {
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxVWG       extendedTextBoxVWG = new ExtendedTextBoxVWG(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapperSpy          = new ExtendedTextBoxMapperSpy(
                extendedTextBoxVWG, propName, true, controlFactory);
            ContactPersonTestBO contactPersonTestBo = new ContactPersonTestBO();

            mapperSpy.BusinessObject = contactPersonTestBo;
            //---------------Assert Precondition----------------
            Assert.IsFalse(mapperSpy.FormClosed);
            //---------------Execute Test ----------------------
            mapperSpy.CallSetupPopupForm();
            mapperSpy.CallSelectClick();
            //---------------Test Result -----------------------
            Assert.IsTrue(mapperSpy.FormClosed);
        }
Exemple #8
0
        public void Test_SelectButtonWhenClicked_AndContactPersonNotValid_ShouldCloseWithoutError_FixBugBug541()
        {
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxVWG       extendedTextBoxVWG = new ExtendedTextBoxVWG(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapperSpy          = new ExtendedTextBoxMapperSpy(
                extendedTextBoxVWG, propName, true, controlFactory);
            ContactPersonTestBO contactPersonTestBo = new ContactPersonTestBO();

            mapperSpy.BusinessObject = contactPersonTestBo;
            mapperSpy.SelectedBO     = new OrganisationTestBO();
            //---------------Assert Precondition----------------
            Assert.IsFalse(mapperSpy.FormClosed);
            Assert.IsFalse(contactPersonTestBo.Status.IsValid());
            Assert.IsTrue(mapperSpy.SelectedBO.Status.IsValid());
            Assert.IsNotNull(mapperSpy.SelectedBO);
            //---------------Execute Test ----------------------
            mapperSpy.CallSetupPopupForm();
            mapperSpy.CallSelectClick();
            //---------------Test Result -----------------------
            Assert.IsFalse(contactPersonTestBo.Status.IsValid());
            Assert.IsTrue(mapperSpy.FormClosed);
        }