Example #1
0
        public void TestToolTip()
        {
            IUIFormField uiProp =
                loader.LoadUIProperty(@"<field property=""testpropname"" toolTipText=""My Tool Tip"" />");

            Assert.AreEqual("My Tool Tip", uiProp.ToolTipText);
        }
        public void Test_GetDefaultUIDef_WhenNotHasViewAndHasStringProp_ShouldCreateUIField()
        {
            //---------------Set up test pack-------------------
            var       viewCreator = new UIViewCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBo).MapClass();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            //---------------Execute Test ----------------------
            IUIDef returnedUIDef = viewCreator.GetDefaultUIDef(classDef);
            //---------------Test Result -----------------------
            IUIForm uiForm = returnedUIDef.UIForm;

            Assert.IsNotNull(uiForm);
            // Assert.AreSame(returnedUIDef, uiForm.UIDef);
            Assert.AreEqual(1, uiForm.Count, "Should create tab");
            IUIFormTab uiFormTab = uiForm[0];

            Assert.AreSame(uiForm, uiFormTab.UIForm);
            Assert.AreEqual("default", uiFormTab.Name);
            Assert.AreEqual(1, uiFormTab.Count, "Should create col");
            IUIFormColumn uiFormColumn = uiFormTab[0];

            Assert.AreSame(uiFormTab, uiFormColumn.UIFormTab);
            Assert.AreEqual(1, uiFormColumn.Count, "Should create field");
            IUIFormField uiFormField = uiFormColumn[0];

            Assert.AreEqual("Fake Bo Name", uiFormField.Label);
            Assert.AreEqual("FakeBoName", uiFormField.PropertyName);
        }
Example #3
0
        public virtual void Test_Load_WhenShowAsCompulsoryNotSet()
        {
            IUIFormField uiProp = loader.LoadUIProperty(@"<field property=""testpropname"" />");
            bool?        privatePropertyValue = uiProp.ShowAsCompulsory;

            Assert.IsFalse(privatePropertyValue.GetValueOrDefault());
            Assert.IsFalse(uiProp.IsCompulsory);
        }
Example #4
0
        public virtual void Test_Load_WhenShowAsCompulsorySet()
        {
            IUIFormField uiProp = loader.LoadUIProperty(@"<field property=""testpropname"" showAsCompulsory=""true"" />");
            bool?        privatePropertyValue = uiProp.ShowAsCompulsory;

            Assert.IsTrue(privatePropertyValue.Value);
            Assert.IsTrue(uiProp.IsCompulsory);
        }
Example #5
0
 /// <summary>
 /// Checks if a form field is in the definition
 /// </summary>
 /// <param name="field">A form field definition</param>
 public bool Contains(IUIFormField field)
 {
     if (field == null)
     {
         return(false);
     }
     return(_list.Contains(field));
 }
Example #6
0
 /// <summary>
 /// Removes a form field from the definition
 /// </summary>
 /// <param name="field">A form field definition</param>
 public void Remove(IUIFormField field)
 {
     if (field == null)
     {
         return;
     }
     _list.Remove(field);
 }
Example #7
0
        private IUIFormField GetFormField(IUIForm uiForm, int index)
        {
            IUIFormTab    uiFormTab    = uiForm[0];
            IUIFormColumn uiFormColumn = uiFormTab[0];
            IUIFormField  uiFormField  = uiFormColumn[index];

            return(uiFormField);
        }
Example #8
0
 /// <summary>
 /// Adds a form field to the definition
 /// </summary>
 /// <param name="field">A form field definition</param>
 public void Add(IUIFormField field)
 {
     if (field == null)
     {
         return;
     }
     field.UIFormColumn = this;
     _list.Add(field);
 }
Example #9
0
        public void TestPropertyAttributes()
        {
            IUIFormField uiProp =
                loader.LoadUIProperty(
                    @"<field label=""testlabel"" property=""testpropname"" ><parameter name=""TestAtt"" value=""TestValue"" /><parameter name=""TestAtt2"" value=""TestValue2"" /></field>");

            Assert.AreEqual("TestValue", uiProp.GetParameterValue("TestAtt"));
            Assert.AreEqual("TestValue2", uiProp.GetParameterValue("TestAtt2"));
        }
Example #10
0
        public void Test_LoadUIProperty_WithCustomMapperType()
        {
            IUIFormField uiProp =
                loader.LoadUIProperty(@"<field property=""testpropname"" mapperType=""MyCustomType"" mapperAssembly=""MyCustomAssembly"" />");

            Assert.AreEqual("testpropname", uiProp.PropertyName);
            Assert.AreEqual("MyCustomType", uiProp.MapperTypeName);
            Assert.AreEqual("MyCustomAssembly", uiProp.MapperAssembly);
        }
Example #11
0
        private void AddFieldToClassDef(IClassDef classDef, IUIFormField uiFormField)
        {
            IUIDef        def    = classDef.UIDefCol["default"];
            IUIForm       form   = def.UIForm;
            IUIFormTab    tab    = form[0];
            IUIFormColumn column = tab[0];

            column.Add(uiFormField);
        }
Example #12
0
        public void TestTypeDefaultsNotSpecified()
        {
            IUIFormField uiProp =
                loader.LoadUIProperty(@"<field label=""testlabel"" property=""testpropname"" />");

            Assert.IsTrue(string.IsNullOrEmpty(uiProp.ControlTypeName));
            Assert.IsTrue(string.IsNullOrEmpty(uiProp.ControlAssemblyName));
            Assert.IsTrue(string.IsNullOrEmpty(uiProp.MapperTypeName));
            Assert.IsTrue(string.IsNullOrEmpty(uiProp.MapperAssembly));
        }
Example #13
0
        public void TestDefaults()
        {
            IUIFormField uiProp =
                loader.LoadUIProperty(@"<field label=""testlabel"" property=""testpropname"" />");

            Assert.AreEqual("testlabel", uiProp.Label);
            Assert.AreEqual("testpropname", uiProp.PropertyName);
            Assert.AreEqual(true, uiProp.Editable);
            Assert.AreEqual(null, uiProp.ToolTipText);
            //Assert.AreEqual(0, uiProp.Triggers.Count);
        }
Example #14
0
        public void TestLayoutStyle()
        {
            //---------------Set up test pack-------------------
            loader = new XmlUIFormFieldLoader(new DtdLoader(), GetDefClassFactory());
            //---------------Execute Test ----------------------
            IUIFormField field = loader.LoadUIProperty(@"<field property=""prop"" layout=""GroupBox"" />");

            //---------------Test Result -----------------------
            Assert.AreEqual(LayoutStyle.GroupBox, field.Layout);
            //---------------Tear Down -------------------------
        }
Example #15
0
        public void TestIsCompulsory_VirtualProp()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef = MyBO.LoadDefaultClassDef();
            IUIFormField field    = classDef.UIDefCol["AlternateVirtualProp"].GetFormField("-MyTestProp-");
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bool isCompulsory = field.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory);
        }
Example #16
0
        public void TestLabelTextHasStarIfCompulsory()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef = MyBO.LoadDefaultClassDef_CompulsoryField_TestProp();
            IUIFormField field    = classDef.UIDefCol["default"].GetFormField("TestProp");
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string labelText = field.GetLabel();

            //---------------Test Result -----------------------
            StringAssert.EndsWith(" *", labelText);
        }
Example #17
0
        public void TestSimpleUIProperty()
        {
            IUIFormField uiProp =
                loader.LoadUIProperty(
                    @"<field label=""testlabel"" property=""testpropname"" type=""TextBox"" assembly=""System.Windows.Forms"" mapperType=""TextBoxMapper"" mapperAssembly=""Habanero.Faces.Base"" editable=""false"" />");

            Assert.AreEqual("testlabel", uiProp.Label);
            Assert.AreEqual("testpropname", uiProp.PropertyName);
            Assert.AreEqual("TextBox", uiProp.ControlTypeName);
            Assert.AreEqual("System.Windows.Forms", uiProp.ControlAssemblyName);
            Assert.AreEqual("Habanero.Faces.Base", uiProp.MapperAssembly);
            Assert.AreEqual("TextBoxMapper", uiProp.MapperTypeName);
            Assert.AreEqual(false, uiProp.Editable);
        }
Example #18
0
        public void Test_GetFormField()
        {
            //---------------Set up test pack-------------------
            UIDefStub uiDef = new UIDefStub();

            uiDef.SetUIForm(GetUiForm());
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IUIFormField formField = uiDef.GetFormField("prop1");

            //---------------Test Result -----------------------
            Assert.AreEqual("prop1", formField.PropertyName);
        }
Example #19
0
        public void Test_GetFormField_NoPropReturnsNull()
        {
            //---------------Set up test pack-------------------
            UIDefStub uiDef = new UIDefStub();

            uiDef.SetUIForm(GetUiForm());
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IUIFormField formField = uiDef.GetFormField("propDoesNotExist");

            //---------------Test Result -----------------------
            Assert.AreEqual(null, formField);
        }
Example #20
0
        public void TestIsCompulsory_True()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef     = MyBO.LoadDefaultClassDef_CompulsoryField_TestProp();
            const string propertyName = "TestProp";
            IUIFormField field        = classDef.UIDefCol["default"].GetFormField(propertyName);

            //---------------Assert Precondition----------------
            Assert.IsTrue(classDef.PropDefcol[propertyName].Compulsory);
            //---------------Execute Test ----------------------
            bool isCompulsory = field.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsTrue(isCompulsory);
        }
Example #21
0
        public void TestIsCompulsory_WhenRelationshipField_AndRelationshipIsNotCompulsory()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWithAssociationRelationship();

            classDef.PropDefcol["RelatedID"].Compulsory = false;
            IUIFormField field = classDef.UIDefCol["default"].GetFormField("MyRelationship");

            //---------------Assert Precondition----------------
            Assert.IsFalse(classDef.RelationshipDefCol["MyRelationship"].IsCompulsory);
            //---------------Execute Test ----------------------
            bool isCompulsory = field.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory);
        }
Example #22
0
 ///<summary>
 /// Inserts a formField. at the specified index.
 /// If Index Less than or equal to zero then the form field wil be inserted at the first postion
 /// If the index is greater than the Count of the list then it will be inserted at the last position.
 ///</summary>
 ///<param name="index">The position at which the formField should be inserted</param>
 ///<param name="formField">The FormField to be iserted.</param>
 public void Insert(int index, IUIFormField formField)
 {
     if (_list.Contains(formField))
     {
         return;
     }
     if (index >= _list.Count)
     {
         index = _list.Count;
     }
     if (index < 0)
     {
         index = 0;
     }
     formField.UIFormColumn = this;
     _list.Insert(index, formField);
 }
Example #23
0
 public void TestLayoutStyle_Invalid()
 {
     //---------------Set up test pack-------------------
     loader = new XmlUIFormFieldLoader(new DtdLoader(), GetDefClassFactory());
     //---------------Execute Test ----------------------
     try
     {
         IUIFormField field = loader.LoadUIProperty(@"<field property=""prop"" layout=""Invalid"" />");
         Assert.Fail("Invalid layout should raise an error");
     }
     //---------------Test Result -----------------------
     catch (InvalidXmlDefinitionException ex)
     {
         StringAssert.Contains("In the definition for the field 'prop' the 'layout' " +
                               "was set to an invalid value ('Invalid'). The valid options are " +
                               "Label and GroupBox.", ex.Message);
     }
     //---------------Tear Down -------------------------
 }
Example #24
0
        public void TestIsCompulsory_WhenBOPropFalse_AndShowAsCompTrue_ShouldBeTrue()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef     = MyBO.LoadDefaultClassDef();
            const string propertyName = "TestProp";
            IUIFormField field        = classDef.UIDefCol["default"].GetFormField(propertyName);

            field.ShowAsCompulsory = true;
            var propDef = classDef.PropDefcol[propertyName];

            //---------------Assert Precondition----------------
            Assert.IsFalse(propDef.Compulsory);
            var showAsCompulsory = field.ShowAsCompulsory;

            Assert.IsTrue((bool)showAsCompulsory);
            //---------------Execute Test ----------------------
            bool isCompulsory = field.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsTrue(isCompulsory);
        }
        public void Test_GetDefaultUIDef_With2Props_ShouldCreate2UIFields()
        {
            //---------------Set up test pack-------------------
            var       viewCreator = new UIViewCreator(GetFactory());
            IClassDef classDef    = typeof(FakeBoW2Props).MapClass();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classDef.UIDefCol.Count);
            Assert.AreEqual(3, classDef.PropDefcol.Count, "2 Props and IDProp");
            //---------------Execute Test ----------------------
            IUIDef returnedUIDef = viewCreator.GetDefaultUIDef(classDef);
            //---------------Test Result -----------------------
            IUIFormField uiFormField1 = GetFormField(returnedUIDef, 0);

            Assert.AreEqual("Fake Bo Name", uiFormField1.Label);
            Assert.AreEqual("FakeBoName", uiFormField1.PropertyName);

            IUIFormField uiFormField2 = GetFormField(returnedUIDef, 1);

            Assert.AreEqual("Fake Bo Name 2", uiFormField2.Label);
            Assert.AreEqual("FakeBoName2", uiFormField2.PropertyName);
        }
Example #26
0
 /// <summary>
 /// Checks if a form field is in the definition
 /// </summary>
 /// <param name="field">A form field definition</param>
 public bool Contains(IUIFormField field)
 {
     if (field == null) return false;
     return _list.Contains(field);
 }
 /// <summary>
 /// Get the name to use for a label control representing a <see cref="IUIFormField"/>.
 /// </summary>
 /// <param name="formField">The <see cref="IUIFormField"/> to represent with the name.</param>
 /// <returns>The suggested name for the label control</returns>
 public string GetLabelControlName(IUIFormField formField)
 {
     return formField.PropertyName + "_Label";
 }
 /// <summary>
 /// Get the name to use for an input control representing a <see cref="IUIFormField"/>.
 /// </summary>
 /// <param name="formField">The <see cref="IUIFormField"/> to represent with the name.</param>
 /// <returns>The suggested name for the input control</returns>
 public string GetInputControlName(IUIFormField formField)
 {
     return formField.PropertyName;
 }
Example #29
0
 ///<summary>
 /// Inserts a formField. at the specified index.
 /// If Index Less than or equal to zero then the form field wil be inserted at the first postion
 /// If the index is greater than the Count of the list then it will be inserted at the last position.
 ///</summary>
 ///<param name="index">The position at which the formField should be inserted</param>
 ///<param name="formField">The FormField to be iserted.</param>
 public void Insert(int index, IUIFormField formField)
 {
     if (_list.Contains(formField)) return;
     if (index >= _list.Count) index = _list.Count;
     if (index < 0) index = 0;
     formField.UIFormColumn = this;
     _list.Insert(index, formField);
 }
Example #30
0
 /// <summary>
 /// Adds a form field to the definition
 /// </summary>
 /// <param name="field">A form field definition</param>
 public void Add(IUIFormField field)
 {
     if(field == null) return;
     field.UIFormColumn = this;
     _list.Add(field);
 }
Example #31
0
 /// <summary>
 /// Removes a form field from the definition
 /// </summary>
 /// <param name="field">A form field definition</param>
 public void Remove(IUIFormField field)
 {
     if (field == null) return;
     _list.Remove(field);
 }
Example #32
0
 /// <summary>
 /// Get the name to use for an input control representing a <see cref="IUIFormField"/>.
 /// </summary>
 /// <param name="formField">The <see cref="IUIFormField"/> to represent with the name.</param>
 /// <returns>The suggested name for the input control</returns>
 public string GetInputControlName(IUIFormField formField)
 {
     return(formField.PropertyName);
 }
Example #33
0
 /// <summary>
 /// Get the name to use for a label control representing a <see cref="IUIFormField"/>.
 /// </summary>
 /// <param name="formField">The <see cref="IUIFormField"/> to represent with the name.</param>
 /// <returns>The suggested name for the label control</returns>
 public string GetLabelControlName(IUIFormField formField)
 {
     return(formField.PropertyName + "_Label");
 }
Example #34
0
 private void AddFieldToClassDef(IClassDef classDef, IUIFormField uiFormField)
 {
     IUIDef def = classDef.UIDefCol["default"];
     IUIForm form = def.UIForm;
     IUIFormTab tab = form[0];
     IUIFormColumn column = tab[0];
     column.Add(uiFormField);
 }