コード例 #1
0
        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());
        }
コード例 #2
0
 public void SetUpTests()
 {
     _comboBox = GetControlFactory().CreateDateRangeComboBox();
     _numDefaultOptions = 14;
     _numAllOptions = Enum.GetNames(typeof (DateRangeOptions)).Length;
     
     // Use a fixed date as the reference point, rather than DateTime.Now
     _comboBox.UseFixedNowDate = true;
 }
コード例 #3
0
 ///<summary>
 /// Constructor with controlFactory, propertyName and filterClauseOperator
 ///</summary>
 ///<param name="controlFactory"></param>
 ///<param name="propertyName"></param>
 ///<param name="filterClauseOperator"></param>
 public DateRangeComboBoxFilter(IControlFactory controlFactory, string propertyName, FilterClauseOperator filterClauseOperator)
 {
     _controlFactory       = controlFactory;
     _propertyName         = propertyName;
     _filterClauseOperator = filterClauseOperator;
     _dateRangeComboBox    = _controlFactory.CreateDateRangeComboBox();
     _dateRangeComboBox.SelectedIndexChanged += (sender, e) => FireValueChanged();
     _dateRangeComboBox.TextChanged          += (sender, e) => FireValueChanged();
 }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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.");
        }
コード例 #7
0
 ///<summary>
 /// Constructor with controlFactory, propertyName and filterClauseOperator
 ///</summary>
 ///<param name="controlFactory"></param>
 ///<param name="propertyName"></param>
 ///<param name="filterClauseOperator"></param>
 public DateRangeComboBoxFilter(IControlFactory controlFactory, string propertyName, FilterClauseOperator filterClauseOperator)
 {
     _controlFactory = controlFactory;
     _propertyName = propertyName;
     _filterClauseOperator = filterClauseOperator;
     _dateRangeComboBox = _controlFactory.CreateDateRangeComboBox();
     _dateRangeComboBox.SelectedIndexChanged += (sender, e) => FireValueChanged();
     _dateRangeComboBox.TextChanged += (sender,e) => FireValueChanged();
 }