public void TestAdd_DateRangeFilterComboBoxExclusive() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); IFilterClauseFactory filterClauseFactory = new DataViewFilterClauseFactory(); DateTime testDate = new DateTime(2007, 1, 2, 3, 4, 5, 6); //---------------Execute Test ---------------------- IDateRangeComboBox dr1 = filterControl.AddDateRangeFilterComboBox("test", "test", false, false); dr1.UseFixedNowDate = true; dr1.FixedNowDate = testDate; dr1.SelectedItem = "Today"; IFilterClause clause1 = filterClauseFactory.CreateDateFilterClause("test", FilterClauseOperator.OpGreaterThan, new DateTime(2007, 1, 2, 0, 0, 0)); IFilterClause clause2 = filterClauseFactory.CreateDateFilterClause("test", FilterClauseOperator.OpLessThan, new DateTime(2007, 1, 2, 23, 59, 59, 999)); IFilterClause compClause = filterClauseFactory.CreateCompositeFilterClause(clause1, FilterClauseCompositeOperator.OpAnd, clause2); //---------------Test Result ----------------------- Assert.AreEqual(compClause.GetFilterClauseString(), filterControl.GetFilterClause().GetFilterClauseString()); }
public void TestAdd_DateRangeFilterComboBox() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); //---------------Execute Test ---------------------- IDateRangeComboBox dr1 = filterControl.AddDateRangeFilterComboBox("test", "test", true, true); //---------------Test Result ----------------------- Assert.AreEqual(1, filterControl.FilterControls.Count); Assert.IsTrue(filterControl.FilterPanel.Controls.Contains(dr1)); }
public void Test_ClearDateRangeComboBoxFilter_ShouldClearTextInCombo() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); IComboBox comboBox = filterControl.AddDateRangeFilterComboBox("Test", "Test"); comboBox.SelectedItem = "Today"; //---------------Assert preconditions--------------- Assert.AreEqual("Today", comboBox.Text); //---------------Execute Test ---------------------- filterControl.ClearFilters(); //---------------Test Result ----------------------- Assert.AreEqual(0, comboBox.SelectedIndex); Assert.AreEqual("(Date Ranges)", comboBox.Text); }
public void TestAdd_DateRangeFilterComboBoxOverload() { //---------------Set up test pack------------------- IFilterControl filterControl = GetControlFactory().CreateFilterControl(); List <DateRangeOptions> options = new List <DateRangeOptions>(); options.Add(DateRangeOptions.Today); options.Add(DateRangeOptions.Yesterday); //---------------Execute Test ---------------------- IDateRangeComboBox dateRangeCombo = filterControl.AddDateRangeFilterComboBox("test", "test", options, true, false); //---------------Test Result ----------------------- Assert.AreEqual(3, dateRangeCombo.Items.Count); }
public void TestChangeDateRangeComboBoxAppliesFilter() { //---------------Set up test pack------------------- IControlFactory factory = GetControlFactory(); IFilterControl ctl = factory.CreateFilterControl(); IDateRangeComboBox dateRangeComboBox = ctl.AddDateRangeFilterComboBox("test", "propname", true, true); string text = TestUtil.GetRandomString(); bool filterFired = false; ctl.Filter += delegate { filterFired = true; }; //---------------Assert Preconditions -------------- Assert.IsFalse(filterFired); //---------------Execute Test ---------------------- dateRangeComboBox.Text = text; //---------------Test Result ----------------------- Assert.IsTrue(filterFired, "The filter event should have been fired when the text was changed."); }