コード例 #1
0
        public void Test_SelectButtonWhenClicked_ShouldApplyBusinessObjectChanges(bool enableEditing)
        {
            //---------------Set up test pack-------------------
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxWin       extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapperSpy          = new ExtendedTextBoxMapperSpy(
                extendedTextBoxWin, propName, true, controlFactory);

            mapperSpy.EnableEditing = enableEditing;
            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);
        }
コード例 #2
0
        public void Test_Construct()
        {
            //--------------- Set up test pack ------------------
            IControlFactory    controlFactory     = GetControlFactory();
            ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            string             propName           = TestUtil.GetRandomString();
            //--------------- Test Preconditions ----------------

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

            //--------------- Test Result -----------------------
            Assert.IsInstanceOf(typeof(IControlMapper), mapper);
            Assert.AreSame(extendedTextBoxWin, 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(extendedTextBoxWin, lookupComboBoxMapper.Control);
            Assert.AreEqual(propName, lookupComboBoxMapper.PropertyName);
            Assert.AreEqual(false, lookupComboBoxMapper.IsReadOnly);
            Assert.AreEqual(controlFactory, lookupComboBoxMapper.ControlFactory);
            Assert.AreEqual(lookupComboBoxMapper.ErrorProvider, mapper.ErrorProvider);
        }
コード例 #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();
            ExtendedTextBoxWin    extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            const string          propName           = "OrganisationID";
            ExtendedTextBoxMapper mapper             = new ExtendedTextBoxMapper(
                extendedTextBoxWin, 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);
        }
コード例 #4
0
        private static ExtendedTextBoxMapper CreateExtendedLookupComboBoxMapper(string propertyName)
        {
            IControlFactory       controlFactory     = GetControlFactory();
            ExtendedTextBoxWin    extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            ExtendedTextBoxMapper mapper             = new ExtendedTextBoxMapper(
                extendedTextBoxWin, propertyName, true, controlFactory);

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

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

            mapper.BusinessObject = new ContactPersonTestBO();
            // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation();
            //--------------- Test Preconditions ----------------
            Assert.IsNull(mapper.PopupForm);
            //--------------- Execute Test ----------------------
            //extendedTextBoxWin.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(BOGridAndEditorControlWin), 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);

            BOGridAndEditorControlWin andBOGridAndEditorControlWin = null;

            foreach (var ctl in form.Controls)
            {
                andBOGridAndEditorControlWin = form.Controls[0] as BOGridAndEditorControlWin;
                if (andBOGridAndEditorControlWin != null)
                {
                    break;
                }
            }
            Assert.IsNotNull(andBOGridAndEditorControlWin, "Can't find BO editor on popup form");
            //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);
        }
コード例 #6
0
        public void Test_CancelButton_WhenClicked_ShouldCancelEditsAndCloseForm()
        {
            //---------------Set up test pack-------------------
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxWin       extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapper             = new ExtendedTextBoxMapperSpy(
                extendedTextBoxWin, 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);
        }
コード例 #7
0
        public void Test_SelectButtonWhenClicked_ShouldClosePopupForm()
        {
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxWin       extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapperSpy          = new ExtendedTextBoxMapperSpy(
                extendedTextBoxWin, 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);
        }
コード例 #8
0
        public void Test_ShowGridAndBOEditorControlWinOnClick()
        {
            //--------------- Set up test pack ------------------
            BusinessObjectCollection <OrganisationTestBO> organisationTestBOs = CreateSavedOrganisationTestBOsCollection();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxWin       extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapper             = new ExtendedTextBoxMapperSpy(
                extendedTextBoxWin, propName, true, controlFactory);

            mapper.BusinessObject = new ContactPersonTestBO();
            // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation();
            //--------------- Test Preconditions ----------------
            Assert.IsNull(mapper.PopupForm);
            //--------------- Execute Test ----------------------
            //extendedTextBoxWin.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(BOGridAndEditorControlWin), form.Controls[0]);
            Assert.IsInstanceOf(typeof(IButtonGroupControl), form.Controls[1]);
            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);
        }
コード例 #9
0
        public void Test_SelectButtonWhenClicked_AndContactPersonNotValid_ShouldCloseWithoutError_FixBugBug541()
        {
            GetClassDefs();
            IControlFactory          controlFactory     = GetControlFactory();
            ExtendedTextBoxWin       extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory);
            const string             propName           = "OrganisationID";
            ExtendedTextBoxMapperSpy mapperSpy          = new ExtendedTextBoxMapperSpy(
                extendedTextBoxWin, 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);
        }