public void Test_BuildFilterControl_Simple() { //---------------Set up test pack------------------- FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory()); string propName = TestUtil.GetRandomString(); FilterDef filterDef = CreateFilterDef_1Property(propName); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- IFilterControl filterControl = builder.BuildFilterControl(filterDef); filterControl.Size = new Size(1000, 800); //---------------Test Result ----------------------- Assert.IsNotNull(filterControl); Assert.AreEqual(1, filterControl.Controls.Count, "Always has GroupBox"); Assert.AreEqual(FilterModes.Filter, filterControl.FilterMode); Assert.AreEqual(1, filterControl.FilterControls.Count); Assert.IsNotNull(filterControl.GetChildControl(propName)); Assert.IsInstanceOf(typeof(StringTextBoxFilter), filterControl.FilterControls[0]); IPanel filterPanel = filterControl.FilterPanel; Assert.AreEqual(2, filterPanel.Controls.Count); IControlHabanero label = filterControl.FilterPanel.Controls[0]; Assert.IsInstanceOf(typeof(ILabel), label); Assert.Greater(label.Width, 0); Assert.Greater(label.Height, 0); Assert.Greater(label.Left, 0); Assert.IsTrue(label.Visible); IControlHabanero textBox = filterControl.FilterPanel.Controls[1]; Assert.IsInstanceOf(typeof(ITextBox), textBox); //Assert.AreEqual(label.Top, textBox.Top); //Assert.GreaterOrEqual(textBox.Left, label.Left + label.Width); }
public void TestAdd_AddBooleanFilterCheckBox_CheckBox__GetControl() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); ICheckBox tbExpected = filterControl.AddBooleanFilterCheckBox("Test:", "TestColumn", false); filterControl.AddStringFilterTextBox("Test2:", "TestColumn2"); //---------------Execute Test ---------------------- ICheckBox tbReturned = (ICheckBox)filterControl.GetChildControl("TestColumn"); //---------------Test Result ----------------------- Assert.AreSame(tbExpected, tbReturned); }
public void TestAdd_TwoStringFilterTextBox_Combo_GetControl() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); IComboBox tbExpected = filterControl.AddStringFilterComboBox("Test:", "TestColumn", new[] { "" }, false); filterControl.AddStringFilterTextBox("Test2:", "TestColumn2"); //---------------Execute Test ---------------------- IComboBox tbReturned = (IComboBox)filterControl.GetChildControl("TestColumn"); //---------------Test Result ----------------------- Assert.AreSame(tbExpected, tbReturned); //---------------Tear Down ------------------------- }
public void TestAdd_AddBooleanFilterComboBox_GetControl() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); IComboBox cbExpected = filterControl.AddBooleanFilterComboBox("Test:", "TestColumn", false); filterControl.AddStringFilterTextBox("Test2:", "TestColumn2"); //---------------Assert Precondition---------------- Assert.IsNotNull(cbExpected); //---------------Execute Test ---------------------- IComboBox cbReturned = (IComboBox)filterControl.GetChildControl("TestColumn"); //---------------Test Result ----------------------- Assert.AreSame(cbExpected, cbReturned); }
public void TestAdd_TwoStringFilterTextBox_DateTime__GetControl() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); IDateTimePicker tbExpected = filterControl.AddDateFilterDateTimePicker("Test:", "TestColumn", DateTime.Now, FilterClauseOperator.OpEquals, false); filterControl.AddStringFilterTextBox("Test2:", "TestColumn2"); //---------------Execute Test ---------------------- IDateTimePicker tbReturned = (IDateTimePicker)filterControl.GetChildControl("TestColumn"); //---------------Test Result ----------------------- Assert.AreSame(tbExpected, tbReturned); //---------------Tear Down ------------------------- }
public void TestAdd_CustomFilter() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); ICustomFilter customFilter = new CustomFilterStub(GetControlFactory()); //---------------Execute Test ---------------------- filterControl.AddCustomFilter("LabelText", customFilter); //---------------Test Result ----------------------- Assert.AreEqual(1, filterControl.FilterControls.Count); IControlHabanero controlHabanero = filterControl.GetChildControl("test"); Assert.AreEqual(customFilter.Control, controlHabanero); Assert.IsNotNull(controlHabanero); Assert.IsInstanceOf(typeof(ITextBox), controlHabanero); //---------------Tear Down ------------------------- }
public void Test_AddCustomFilter_WhenControlIsNull_ShouldNotAddToVisualLayout() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); var customFilter = new CustomFilterStub(GetControlFactory()); customFilter.SetBox(null); const string propertyName = "test"; //---------------Assert Precondition---------------- Assert.IsNull(customFilter.Control); Assert.AreEqual(propertyName, customFilter.PropertyName); //---------------Execute Test ---------------------- filterControl.AddCustomFilter(RandomValueGen.GetRandomString(), customFilter); //---------------Test Result ----------------------- Assert.AreEqual(1, filterControl.FilterControls.Count, "Should Be Added To The Set Of CustomFilters"); IControlHabanero controlHabanero = filterControl.GetChildControl(propertyName); Assert.IsNull(controlHabanero, "No control should be added since the custom filter is a non visual filter"); }