Example #1
0
        public void TestAddDateFilterDateTimePicker_Composites()
        {
            //---------------Set up test pack-------------------
            IControlFactory      factory             = GetControlFactory();
            IFilterClauseFactory filterClauseFactory = new DataViewFilterClauseFactory();
            IFilterControl       filterControl       = factory.CreateFilterControl();
            DateTime             testDate1           = DateTime.Now;
            DateTime             testDate2           = testDate1.AddDays(1);

            filterControl.AddDateFilterDateTimePicker("test1:", "TestColumn1", testDate1, FilterClauseOperator.OpLessThan, false);
            filterControl.AddDateFilterDateTimePicker("test2:", "TestColumn2", testDate2, FilterClauseOperator.OpLessThan, false);

            //---------------Execute Test ----------------------
            string expectedFilterClause = filterControl.GetFilterClause().GetFilterClauseString();

            //---------------Test Result -----------------------
            IFilterClause clause1 =
                filterClauseFactory.CreateDateFilterClause("TestColumn1", FilterClauseOperator.OpLessThan, new DateTime(testDate1.Year, testDate1.Month, testDate1.Day));
            IFilterClause clause2 =
                filterClauseFactory.CreateDateFilterClause("TestColumn2", FilterClauseOperator.OpLessThan, new DateTime(testDate2.Year, testDate2.Month, testDate2.Day));
            IFilterClause compClause =
                filterClauseFactory.CreateCompositeFilterClause(clause1, FilterClauseCompositeOperator.OpAnd, clause2);

            Assert.AreEqual(compClause.GetFilterClauseString(), expectedFilterClause);

            //---------------Tear Down -------------------------
        }
        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 Test_Search_CompositeEqualsWithAnd_Date()
        {
            //---------------Set up test pack-------------------

            IFilterClause clause1 =
                filterClauseFactory.CreateDateFilterClause("h a", FilterClauseOperator.OpEquals, DateTime.Now);
            IFilterClause clause2 =
                filterClauseFactory.CreateDateFilterClause("h a", FilterClauseOperator.OpEquals, DateTime.Now);
            IFilterClause compositeClause =
                filterClauseFactory.CreateCompositeFilterClause(clause1, FilterClauseCompositeOperator.OpAnd, clause2);

            string expectedDateString       = DateTime.Now.ToString("dd MMM yyyy HH:mm:ss");
            string expectedDateFilterClause = string.Format("([h a] = '{0}') and ([h a] = '{0}')", expectedDateString);
            //---------------Execute Test ----------------------

            string expectedFilterString = compositeClause.GetFilterClauseString("%", "'");

            //---------------Test Result -----------------------

            Assert.AreEqual(expectedDateFilterClause, expectedFilterString);
        }
Example #4
0
        public void TestAddDateFilterDateTimePicker_DefaultDateCorrect()
        {
            //---------------Set up test pack-------------------
            IControlFactory      factory             = GetControlFactory();
            IFilterClauseFactory filterClauseFactory = new DataViewFilterClauseFactory();
            IFilterControl       filterControl       = factory.CreateFilterControl();
            DateTime             testDate            = DateTime.Today.AddDays(-2);

            //---------------Execute Test ----------------------
            filterControl.AddDateFilterDateTimePicker("test:", "TestColumn", testDate, FilterClauseOperator.OpGreaterThan, false);
            string expectedFilterClause = filterControl.GetFilterClause().GetFilterClauseString();
            //---------------Test Result -----------------------
            IFilterClause clause =
                filterClauseFactory.CreateDateFilterClause("TestColumn", FilterClauseOperator.OpGreaterThan, new DateTime(testDate.Year, testDate.Month, testDate.Day));

            Assert.AreEqual(clause.GetFilterClauseString(), expectedFilterClause);
            //---------------Tear Down -------------------------
        }
Example #5
0
        public void TestAddDateFilterDateTimePicker_OpLessThanOrEqualToOperator()
        {
            //---------------Set up test pack-------------------
            IControlFactory      factory             = GetControlFactory();
            IFilterClauseFactory filterClauseFactory = new DataViewFilterClauseFactory();
            IFilterControl       filterControl       = factory.CreateFilterControl();
            DateTime             testDate            = DateTime.Today.AddDays(-2);
            IDateTimePicker      dtePicker           = filterControl.AddDateFilterDateTimePicker("test:", "TestColumn", testDate, FilterClauseOperator.OpLessThanOrEqualTo, false);
            //---------------Execute Test ----------------------
            DateTime newDateTime = DateTime.Today.AddDays(+4);

            dtePicker.Value = newDateTime;
            string expectedFilterClause = filterControl.GetFilterClause().GetFilterClauseString();
            //---------------Test Result -----------------------
            IFilterClause clause =
                filterClauseFactory.CreateDateFilterClause("TestColumn", FilterClauseOperator.OpLessThanOrEqualTo, new DateTime(newDateTime.Year, newDateTime.Month, newDateTime.Day));

            Assert.AreEqual(clause.GetFilterClauseString(), expectedFilterClause);

            //---------------Tear Down -------------------------
        }