///<summary> ///Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>. ///</summary> /// ///<returns> ///true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false. ///</returns> /// ///<param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>. </param><filterpriority>2</filterpriority> public override bool Equals(object obj) { UIFormColumn otherFormColumn = obj as UIFormColumn; if ((object)otherFormColumn == null) { return(false); } if (otherFormColumn.Count != this.Count) { return(false); } if (otherFormColumn.Width != this.Width) { return(false); } foreach (UIFormField field in this) { bool found = false; foreach (UIFormField otherFormField in otherFormColumn) { if (otherFormField.Equals(field)) { found = true; } } if (!found) { return(false); } } return(true); }
public void TestRemove() { UIFormColumn column = new UIFormColumn(); UIFormTab uiFormTab = new UIFormTab(); uiFormTab.Add(column); Assert.IsTrue(uiFormTab.Contains(column)); uiFormTab.Remove(column); Assert.IsFalse(uiFormTab.Contains(column)); }
public void TestRemove() { UIFormField field = CreateUIFormField(); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field); Assert.IsTrue(uiFormColumn.Contains(field)); uiFormColumn.Remove(field); Assert.IsFalse(uiFormColumn.Contains(field)); }
///<summary> /// Clones the collection. ///</summary> ///<returns>a new collection that is a shallow copy of this collection</returns> public IUIFormColumn Clone() { UIFormColumn newPropDefCol = new UIFormColumn(); newPropDefCol.Width = this.Width; foreach (UIFormField def in this) { newPropDefCol.Add(def); } return(newPropDefCol); }
public void TestCopyTo() { UIFormColumn column1 = new UIFormColumn(); UIFormColumn column2 = new UIFormColumn(); UIFormTab uiFormTab = new UIFormTab(); uiFormTab.Add(column1); uiFormTab.Add(column2); UIFormColumn[] target = new UIFormColumn[2]; uiFormTab.CopyTo(target, 0); Assert.AreEqual(column1, target[0]); Assert.AreEqual(column2, target[1]); }
public void TestCopyTo() { UIFormField field1 = CreateUIFormField(); UIFormField field2 = CreateUIFormField(); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); UIFormField[] target = new UIFormField[2]; uiFormColumn.CopyTo(target, 0); Assert.AreEqual(field1, target[0]); Assert.AreEqual(field2, target[1]); }
public void Test_Construct_WithUIFormColumns() { //---------------Set up test pack------------------- UIFormField uiFormField1 = new UIFormField("label1", "prop1"); UIFormField uiFormField2 = new UIFormField("label2", "prop2"); UIFormField uiFormField3 = new UIFormField("label3", "prop3"); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- UIFormColumn uiFormColumn = new UIFormColumn(uiFormField1, uiFormField2, uiFormField3); //---------------Test Result ----------------------- Assert.AreEqual(3, uiFormColumn.Count); Assert.AreSame(uiFormField1, uiFormColumn[0]); Assert.AreSame(uiFormField2, uiFormColumn[1]); Assert.AreSame(uiFormField3, uiFormColumn[2]); }
public void Test_Construct_WithUIFormColumns() { //---------------Set up test pack------------------- UIFormColumn uiFormColumn1 = new UIFormColumn(); UIFormColumn uiFormColumn2 = new UIFormColumn(); UIFormColumn uiFormColumn3 = new UIFormColumn(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- UIFormTab uiFormTab = new UIFormTab(uiFormColumn1, uiFormColumn2, uiFormColumn3); //---------------Test Result ----------------------- Assert.AreEqual(3, uiFormTab.Count); Assert.AreSame(uiFormColumn1, uiFormTab[0]); Assert.AreSame(uiFormColumn2, uiFormTab[1]); Assert.AreSame(uiFormColumn3, uiFormTab[2]); }
public void TestAddUIFormField() { //---------------Set up test pack------------------- UIFormField field1 = CreateUIFormField("label1", "prop1"); UIFormColumn uiFormColumn = new UIFormColumn(); //---------------Assert Precondition---------------- Assert.IsNull(field1.UIFormColumn); //---------------Execute Test ---------------------- uiFormColumn.Add(field1); //---------------Test Result ----------------------- Assert.AreSame(uiFormColumn, field1.UIFormColumn); }
public void GetRowSpanForColumnToTheRight_TwoColumns() { //---------------Set up test pack------------------- Hashtable parameters1 = new Hashtable(); parameters1.Add("rowSpan", 1); parameters1.Add("colSpan", 3); UIFormField field1 = CreateUIFormField("label2", "prop2", parameters1); Hashtable parameters2 = new Hashtable(); parameters2.Add("rowSpan", 2); parameters2.Add("colSpan", 2); UIFormField field2 = CreateUIFormField("label2", "prop2", parameters2); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); //---------------Execute Test ---------------------- int rowsPanForColumnToTheRight1 = uiFormColumn.GetRowSpanForColumnToTheRight(1); int rowsPanForColumnToTheRight2 = uiFormColumn.GetRowSpanForColumnToTheRight(2); //---------------Test Result ----------------------- Assert.AreEqual(3, rowsPanForColumnToTheRight1); Assert.AreEqual(1, rowsPanForColumnToTheRight2); }
public UIFormColumn CreateUIFormColumn_1Field(string propName) { UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(CreateUIFormField("label1", propName, null)); return uiFormColumn; }
public void Test_Insert_WhenIndexNegative_AddsItemToBeginOfList() { //---------------Set up test pack------------------- UIFormColumn column = new UIFormColumn(); UIFormField field = GetNewFormField(); column.Insert(0, GetNewFormField()); //---------------Assert Precondition---------------- Assert.AreEqual(1, column.Count); Assert.AreNotSame(field, column[0]); //---------------Execute Test ---------------------- column.Insert(-1, field); //---------------Test Result ----------------------- Assert.AreEqual(2, column.Count); Assert.AreSame(field, column[0]); }
public void Test_Insert_WhenOneItem_ShouldInsertFieldAtIndex() { //---------------Set up test pack------------------- UIFormColumn column = new UIFormColumn(); UIFormField field = GetNewFormField(); column.Insert(0, GetNewFormField()); //---------------Assert Precondition---------------- Assert.AreEqual(1, column.Count); Assert.AreNotSame(field, column[0]); //---------------Execute Test ---------------------- column.Insert(0, field); //---------------Test Result ----------------------- Assert.AreEqual(2, column.Count); Assert.AreSame(field, column[0]); }
public void Test_NotEquals() { UIFormColumn uiFormColumn1 = new UIFormColumn(); UIFormField def = CreateUIFormField("bob", "bob"); uiFormColumn1.Add(def); UIFormColumn uiFormColumn2 = new UIFormColumn(); UIFormField def2 = CreateUIFormField("bob1", "bob1"); uiFormColumn2.Add(def2); Assert.IsFalse(uiFormColumn1 == uiFormColumn2); Assert.IsFalse(uiFormColumn2 == uiFormColumn1); Assert.IsFalse(uiFormColumn1.Equals(uiFormColumn2)); Assert.IsFalse(uiFormColumn1.Equals((object)uiFormColumn2)); }
public void Test_NotEqualsDiffFieldCount() { //---------------Set up test pack------------------- UIFormColumn uiFormColumn1 = new UIFormColumn(); UIFormField def = CreateUIFormField("bob", "bob"); uiFormColumn1.Add(def); UIFormColumn uiFormColumn2 = new UIFormColumn(); uiFormColumn2.Add(def); UIFormField def2 = CreateUIFormField("bob1", "bob1"); uiFormColumn1.Add(def); uiFormColumn1.Add(def2); uiFormColumn2.Add(def2); //--------------Assert PreConditions---------------- Assert.AreNotEqual(uiFormColumn1.Count, uiFormColumn2.Count); //---------------Execute Test ---------------------- bool operatorEquals = uiFormColumn1 == uiFormColumn2; bool equalsMethod = uiFormColumn1.Equals(uiFormColumn2); bool equalsObjectMethod = uiFormColumn1.Equals((object)uiFormColumn2); //---------------Test Result ----------------------- Assert.IsFalse(operatorEquals); Assert.IsFalse(equalsMethod); Assert.IsFalse(equalsObjectMethod); //---------------Tear Down ------------------------- }
public void Test_NotEquals_SameFirstItemDiffSecondItem() { UIFormColumn uiFormColumn1 = new UIFormColumn(); UIFormField def = CreateUIFormField("bob", "bob"); uiFormColumn1.Add(def); UIFormColumn uiFormColumn2 = new UIFormColumn(); uiFormColumn2.Add(def); UIFormField def2 = CreateUIFormField("bob1", "bob1"); uiFormColumn2.Add(def2); Assert.IsFalse(uiFormColumn1 == uiFormColumn2); Assert.IsTrue(uiFormColumn1 != uiFormColumn2); Assert.IsFalse(uiFormColumn2 == uiFormColumn1); Assert.IsFalse(uiFormColumn1.Equals(uiFormColumn2)); Assert.IsFalse(uiFormColumn1.Equals((object)uiFormColumn2)); }
public void TestEquals() { UIFormColumn uiFormColumn1 = new UIFormColumn(); UIFormField def = CreateUIFormField(); uiFormColumn1.Add(def); UIFormColumn uiFormColumn2 = new UIFormColumn(); uiFormColumn2.Add(def); Assert.IsTrue(uiFormColumn1 == uiFormColumn2); Assert.IsTrue(uiFormColumn2 == uiFormColumn1); Assert.IsFalse(uiFormColumn2 != uiFormColumn1); Assert.IsTrue(uiFormColumn1.Equals(uiFormColumn2)); Assert.IsTrue(uiFormColumn1.Equals((object)uiFormColumn2)); }
public void Test_NotEqualsNull() { UIFormColumn uiFormColumn1 = new UIFormColumn(); const UIFormColumn uiFormColumn2 = null; Assert.IsFalse(uiFormColumn1 == uiFormColumn2); Assert.IsFalse(uiFormColumn2 == uiFormColumn1); Assert.IsFalse(uiFormColumn1.Equals(uiFormColumn2)); Assert.IsFalse(uiFormColumn1.Equals((object)uiFormColumn2)); }
public void TestCloneUIFormTab() { //---------------Set up test pack------------------- UIFormField field1 = CreateUIFormField("label1", "prop1", null); UIFormField field2 = CreateUIFormField("label2", "prop2", null); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); UIFormTab uiFormTab = new UIFormTab("Tab1"); uiFormTab.Add(uiFormColumn); //---------------Execute Test ---------------------- IUIFormTab clonedFormTab = uiFormTab.Clone(); //---------------Test Result ----------------------- Assert.IsTrue(uiFormTab == (UIFormTab) clonedFormTab); Assert.IsTrue(uiFormTab.Equals(clonedFormTab)); Assert.AreEqual(uiFormTab[0], clonedFormTab[0], "Should be a deep copy and the columns should be equal but copied"); Assert.AreNotSame(uiFormTab[0], clonedFormTab[0], "Should be a deep copy and the columns should be equal but copied (not same)"); }
public void TestFormTab() { //---------------Set up test pack------------------- UIFormColumn column = new UIFormColumn(); UIFormTab tab = new UIFormTab(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- column.UIFormTab = tab; //---------------Test Result ----------------------- Assert.AreSame(tab, column.UIFormTab); }
public void Test_Insert_WhenNoItems_ShouldInsertInfirstLocation() { //---------------Set up test pack------------------- UIFormColumn column = new UIFormColumn(); UIFormField field = GetNewFormField(); //---------------Assert Precondition---------------- Assert.AreEqual(0, column.Count); //---------------Execute Test ---------------------- column.Insert(0, field); //---------------Test Result ----------------------- Assert.AreEqual(1, column.Count); Assert.AreSame(field, column[0]); Assert.AreSame(column, field.UIFormColumn); }
public void TestCloneUIFormColumn() { //---------------Set up test pack------------------- UIFormField field1 = CreateUIFormField(); UIFormField field2 = CreateUIFormField(); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); uiFormColumn.Width = 44; //---------------Execute Test ---------------------- IUIFormColumn clonedFormColumn = uiFormColumn.Clone(); //---------------Test Result ----------------------- Assert.IsTrue(uiFormColumn == (UIFormColumn) clonedFormColumn); Assert.IsTrue(uiFormColumn.Equals(clonedFormColumn)); Assert.AreSame(uiFormColumn[0], clonedFormColumn[0]); }
public void Test_Insert_WhenFieldAlreadyExists_DoesNothing() { //---------------Set up test pack------------------- UIFormColumn column = new UIFormColumn(); UIFormField field = GetNewFormField(); column.Insert(0, field); //---------------Assert Precondition---------------- Assert.AreEqual(1, column.Count); Assert.AreSame(field, column[0]); //---------------Execute Test ---------------------- column.Insert(0, field); //---------------Test Result ----------------------- Assert.AreEqual(1, column.Count); Assert.AreSame(field, column[0]); }
public void TestFormColumn() { //---------------Set up test pack------------------- UIFormField uiFormField1 = CreateFormField(); UIFormColumn column = new UIFormColumn(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- uiFormField1.UIFormColumn = column; //---------------Test Result ----------------------- Assert.AreSame(column, uiFormField1.UIFormColumn); }
public void Test_NotEquals_FormColumnWidthDiff() { //---------------Set up test pack------------------- UIFormColumn uiFormColumn1 = new UIFormColumn(10); UIFormColumn uiFormColumn2 = new UIFormColumn(20); //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- Assert.IsFalse(uiFormColumn1 == uiFormColumn2); Assert.IsFalse(uiFormColumn2 == uiFormColumn1); Assert.IsFalse(uiFormColumn1.Equals(uiFormColumn2)); Assert.IsFalse(uiFormColumn1.Equals((object)uiFormColumn2)); //---------------Test Result ----------------------- //---------------Tear Down ------------------------- }
public void TestAddColumn() { //---------------Set up test pack------------------- UIFormColumn uiFormColumn = new UIFormColumn(); UIFormTab uiFormTab = new UIFormTab(); //---------------Assert Precondition---------------- Assert.IsNull(uiFormColumn.UIFormTab); //---------------Execute Test ---------------------- uiFormTab.Add(uiFormColumn); //---------------Test Result ----------------------- Assert.AreSame(uiFormTab, uiFormColumn.UIFormTab); }
public void TestSync() { UIFormColumn uiFormColumn = new UIFormColumn(); Assert.AreEqual(typeof(object), uiFormColumn.SyncRoot.GetType()); Assert.IsFalse(uiFormColumn.IsSynchronized); }
public void TestEqualsDifferentType() { UIFormColumn uiFormColumn1 = new UIFormColumn(); Assert.AreNotEqual(uiFormColumn1, "bob"); }
private static ClassDef GetClassDef() { PropDef propDefPK = new PropDef(ENUM_PKPROP_NAME, typeof(Guid), PropReadWriteRule.WriteNew, null); PropDef propDef = new PropDef(ENUM_PROP_NAME, typeof(TestEnum), PropReadWriteRule.ReadWrite, TestEnum.Option1); PropDef propDef2 = new PropDef(ENUM_PROP_NAME_EMPTY, typeof(TestEnumEmpty), PropReadWriteRule.ReadWrite, null); PropDef propDef3 = new PropDef(ENUM_PROP_NAME_PASCAL, typeof(TestEnumPascalCase), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef primaryKeyDef = new PrimaryKeyDef { propDefPK }; PropDefCol propDefCol = new PropDefCol { propDefPK, propDef, propDef2, propDef3 }; UIFormField uiFormField = new UIFormField(TestUtil.GetRandomString(), propDef.PropertyName, typeof(IComboBox), "EnumComboBoxMapper", "Habanero.Faces.Base", true, null, null, LayoutStyle.Label); UIFormColumn uiFormColumn = new UIFormColumn { uiFormField }; UIFormTab uiFormTab = new UIFormTab { uiFormColumn }; UIForm uiForm = new UIForm { uiFormTab }; UIDef uiDef = new UIDef("default", uiForm, null); UIDefCol uiDefCol = new UIDefCol { uiDef }; ClassDef classDef = new ClassDef(typeof(EnumBO), primaryKeyDef, propDefCol, new KeyDefCol(), null, uiDefCol); return classDef; }
public void TestGetRowsRequired() { //---------------Set up test pack------------------- UIFormField field1 = CreateUIFormField("label1", "prop1"); Hashtable parameters = new Hashtable(); parameters.Add("rowSpan", 2); UIFormField field2 = CreateUIFormField("label2", "prop2", parameters); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); //---------------Assert Precondition---------------- Assert.AreEqual(2, uiFormColumn.Count); //---------------Execute Test ---------------------- int rowsRequired = uiFormColumn.GetRowsRequired(); //---------------Test Result ----------------------- Assert.AreEqual(3, rowsRequired); }
private static UIForm GetUiForm() { UIFormField field1 = new UIFormField("label1", "prop1", "control", null, null, null, true, null, null, null, LayoutStyle.Label); UIFormField field2 = new UIFormField("label2", "prop2", "control", null, null, null, true, null, null, null, LayoutStyle.Label); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); UIFormTab uiFormTab = new UIFormTab("Tab1"); uiFormTab.Add(uiFormColumn); UIForm uiForm = new UIForm(); uiForm.Add(uiFormTab); uiForm.Title = "ddd"; uiForm.Height = 1; uiForm.Width = 3; return uiForm; }
public void GetRowSpanForColumnToTheRight_One() { //---------------Set up test pack------------------- Hashtable parameters = new Hashtable(); parameters.Add("rowSpan", 1); parameters.Add("colSpan", 2); UIFormField field2 = CreateUIFormField("label2", "prop2", parameters); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field2); //---------------Execute Test ---------------------- int rowsPanForColumnToTheRight = uiFormColumn.GetRowSpanForColumnToTheRight(1); //---------------Test Result ----------------------- Assert.AreEqual(1, rowsPanForColumnToTheRight); }