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); }
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); }
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); }
/// <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> /// 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); }
private IUIFormField GetFormField(IUIForm uiForm, int index) { IUIFormTab uiFormTab = uiForm[0]; IUIFormColumn uiFormColumn = uiFormTab[0]; IUIFormField uiFormField = uiFormColumn[index]; return(uiFormField); }
/// <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); }
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")); }
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); }
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); }
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)); }
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); }
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 ------------------------- }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
///<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); }
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 ------------------------- }
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); }
/// <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; }
///<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); }
/// <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); }
/// <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); }
/// <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); }
/// <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"); }