BuildPanelForTab() public method

Constructs a panel for editing the data of a single instance of a BusinessObject, using the control layout as specified in a UIFormTab object.
public BuildPanelForTab ( UIFormTab formTab ) : IPanelInfo
formTab UIFormTab The tab object that indicates which controls /// to create and how the controls are laid out
return IPanelInfo
 public void Test_UpdateErrorProviderError_WhenBOInvalid_ShouldNotChangeMessageAsAlreadyUpdatedForWin()
 {
     //---------------Set up test pack-------------------
     ContactPersonTestBO.LoadDefaultClassDefWithUIDef();
     ContactPersonTestBO person = ContactPersonTestBO.CreateUnsavedContactPerson("", "");
     Habanero.Faces.Base.PanelBuilder panelBuilder = new Habanero.Faces.Base.PanelBuilder(GetControlFactory());
     IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab) person.ClassDef.UIDefCol["default"].UIForm[0]);
     person.Surname = TestUtil.GetRandomString();
     panelInfo.BusinessObject = person;
     IControlMapper SurnameControlMapper = panelInfo.FieldInfos["Surname"].ControlMapper;
     person.Surname = "";
     //---------------Assert Precondition----------------
     Assert.IsFalse(person.Status.IsValid());
     Assert.AreNotEqual("", SurnameControlMapper.GetErrorMessage());
     //---------------Execute Test ----------------------
     panelInfo.UpdateErrorProvidersErrorMessages();
     //---------------Test Result -----------------------
     Assert.AreNotEqual("", SurnameControlMapper.GetErrorMessage());
 }
        public void Test_BuildPanelForTab_tabNull()
        {
            //---------------Set up test pack-------------------
            PanelBuilder panelBuilder = new PanelBuilder(this.GetControlFactory());

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                panelBuilder.BuildPanelForTab(null);
                Assert.Fail("expected ArgumentNullException");
            }
                //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("Value cannot be null", ex.Message);
                StringAssert.Contains("formTab", ex.ParamName);
            }
        }
        public void Test_BuildPanelForTab_Parameter_SetAlignment_NumericUpDown()
        {
            //---------------Set up test pack-------------------
            Sample.SampleUserInterfaceMapper interfaceMapper = GetSampleUserInterfaceMapper();
            UIFormTab singleFieldTab = interfaceMapper.GetFormTabOneFieldsWithNumericUpDown();

            Habanero.Faces.Base.PanelBuilder panelBuilder = CreatePanelBuilder();
            //---------------Assert Precondition----------------
            Assert.AreEqual("right", ((UIFormField)singleFieldTab[0][0]).Alignment);

            //---------------Execute Test ----------------------
            IPanel panel = panelBuilder.BuildPanelForTab(singleFieldTab).Panel;

            //---------------Test Result -----------------------

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[1]);
            INumericUpDown control = (INumericUpDown)panel.Controls[1];

            Assert.AreEqual(HorizontalAlignment.Right, control.TextAlign);
        }
Esempio n. 4
0
        public void Test_UpdateErrorProviderError_WhenBOInvalid_ShouldSetErrorMessage()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO.LoadDefaultClassDefWithUIDef();
            ContactPersonTestBO person = ContactPersonTestBO.CreateUnsavedContactPerson("", "");

            Habanero.Faces.Base.PanelBuilder panelBuilder = new Habanero.Faces.Base.PanelBuilder(GetControlFactory());
            IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab)person.ClassDef.UIDefCol["default"].UIForm[0]);

            person.Surname           = TestUtil.GetRandomString();
            panelInfo.BusinessObject = person;
            IControlMapper SurnameControlMapper = panelInfo.FieldInfos["Surname"].ControlMapper;

            person.Surname = "";
            //---------------Assert Precondition----------------
            Assert.IsFalse(person.Status.IsValid());
            Assert.AreEqual("", SurnameControlMapper.GetErrorMessage());
            //---------------Execute Test ----------------------
            panelInfo.UpdateErrorProvidersErrorMessages();
            //---------------Test Result -----------------------
            Assert.AreNotEqual("", SurnameControlMapper.GetErrorMessage());
        }
        public void Test_BuildPanelForTab_Parameter_SetNumericUpDownAlignment()
        {
            //---------------Set up test pack-------------------
            Sample.SampleUserInterfaceMapper interfaceMapper = GetSampleUserInterfaceMapper();
            UIFormTab singleFieldTab = interfaceMapper.GetFormTabOneFieldsWithAlignment_NumericUpDown();

            Habanero.Faces.Base.PanelBuilder panelBuilder = CreatePanelBuilder();
            //---------------Assert Precondition----------------
            Assert.AreEqual("left", ((UIFormField)singleFieldTab[0][0]).Alignment);
            Assert.AreEqual("right", ((UIFormField)singleFieldTab[0][1]).Alignment);
            Assert.AreEqual("center", ((UIFormField)singleFieldTab[0][2]).Alignment);
            Assert.AreEqual("centre", ((UIFormField)singleFieldTab[0][3]).Alignment);
            //---------------Execute Test ----------------------
            IPanel panel = panelBuilder.BuildPanelForTab(singleFieldTab).Panel;

            //---------------Test Result -----------------------

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[1]);
            INumericUpDown control1 = (INumericUpDown)panel.Controls[1];

            Assert.AreEqual(HorizontalAlignment.Left, control1.TextAlign);

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN + 1]);
            INumericUpDown control2 = (INumericUpDown)panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN + 1];

            Assert.AreEqual(HorizontalAlignment.Right, control2.TextAlign);

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 2 + 1]);
            INumericUpDown control3 = (INumericUpDown)panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 2 + 1];

            Assert.AreEqual(HorizontalAlignment.Center, control3.TextAlign);

            Assert.IsInstanceOf(typeof(INumericUpDown), panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 3 + 1]);
            INumericUpDown control4 = (INumericUpDown)panel.Controls[Habanero.Faces.Base.PanelBuilder.CONTROLS_PER_COLUMN * 3 + 1];

            Assert.AreEqual(HorizontalAlignment.Center, control4.TextAlign);
        }
Esempio n. 6
0
 public void Test_UpdateErrorProviderError_WhenBOValid_ShouldClearErrorMessage()
 {
     //---------------Set up test pack-------------------
     ContactPersonTestBO.LoadDefaultClassDefWithUIDef();
     ContactPersonTestBO person = ContactPersonTestBO.CreateUnsavedContactPerson("", "");
     PanelBuilder panelBuilder = new PanelBuilder(GetControlFactory());
     IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab) person.ClassDef.UIDefCol["default"].UIForm[0]);
     panelInfo.BusinessObject = person;
     IControlMapper SurnameControlMapper = panelInfo.FieldInfos["Surname"].ControlMapper;
     panelInfo.UpdateErrorProvidersErrorMessages();
     //---------------Assert Precondition----------------
     Assert.AreNotEqual("", SurnameControlMapper.GetErrorMessage());
     //---------------Execute Test ----------------------
     person.Surname = "SomeValue";
     panelInfo.UpdateErrorProvidersErrorMessages();
     //---------------Test Result -----------------------
     Assert.AreEqual("", SurnameControlMapper.GetErrorMessage());
 }
Esempio n. 7
0
        public void Test_UIFormTab()
        {
            //--------------- Set up test pack ------------------
            IClassDef classDef = Sample.CreateClassDefWithTwoPropsOneInteger();
            PanelBuilder panelBuilder = new PanelBuilder(GetControlFactory());
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab) classDef.UIDefCol["default"].UIForm[0]);

            //--------------- Test Result -----------------------
            Assert.IsNotNull(panelInfo.UIFormTab);
            Assert.AreEqual(panelInfo.UIFormTab.Name, panelInfo.PanelTabText);
        }
Esempio n. 8
0
        public void TestClearErrorProviders()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = Sample.CreateClassDefWithTwoPropsOneCompulsory();
            PanelBuilder panelBuilder = new PanelBuilder(GetControlFactory());
            IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab) classDef.UIDefCol["default"].UIForm[0]);
            Sample businessObject = new Sample();

            panelInfo.BusinessObject = businessObject;

            //businessObject.SetPropertyValue("SampleText2", "sdlkfj");
            PanelInfo.FieldInfo fieldInfo = panelInfo.FieldInfos["SampleText2"];
            panelInfo.ApplyChangesToBusinessObject();
            IErrorProvider errorProvider = fieldInfo.ControlMapper.ErrorProvider;

            //---------------Assert Precondition----------------
            Assert.IsTrue(errorProvider.GetError(fieldInfo.InputControl).Length > 0);
            //---------------Execute Test ----------------------
            panelInfo.ClearErrorProviders();
            //---------------Test Result -----------------------
            Assert.IsFalse(errorProvider.GetError(fieldInfo.InputControl).Length > 0);
        }
Esempio n. 9
0
 public void TestControlsVisible()
 {
     //---------------Set up test pack-------------------
     IClassDef classDef = Sample.CreateClassDefWithTwoPropsOneInteger();
     PanelBuilder panelBuilder = new PanelBuilder(GetControlFactory());
     IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab) classDef.UIDefCol["default"].UIForm[0]);
     panelInfo.BusinessObject = new Sample();
     //---------------Assert Precondition----------------
     Assert.IsTrue(panelInfo.FieldInfos[0].InputControl.Visible);
     Assert.IsTrue(panelInfo.FieldInfos[1].InputControl.Visible);
     //---------------Execute Test ----------------------
     panelInfo.ControlsVisible = false;
     //---------------Test Result -----------------------
     Assert.IsFalse(panelInfo.FieldInfos[0].InputControl.Visible);
     Assert.IsFalse(panelInfo.FieldInfos[1].InputControl.Visible);
 }