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 TestTwoStringTextBoxFilter() { //---------------Set up test pack------------------- IFilterClauseFactory itsFilterClauseFactory = new DataViewFilterClauseFactory(); IFilterControl filterControl = GetControlFactory().CreateFilterControl(); ITextBox tb = filterControl.AddStringFilterTextBox("Test:", "TestColumn"); tb.Text = "testvalue"; ITextBox tb2 = filterControl.AddStringFilterTextBox("Test:", "TestColumn2"); tb2.Text = "testvalue2"; //---------------Execute Test ---------------------- string filterClauseString = filterControl.GetFilterClause().GetFilterClauseString(); //---------------Test Result ----------------------- IFilterClause clause1 = itsFilterClauseFactory.CreateStringFilterClause("TestColumn", FilterClauseOperator.OpLike, "testvalue"); IFilterClause clause2 = itsFilterClauseFactory.CreateStringFilterClause("TestColumn2", FilterClauseOperator.OpLike, "testvalue2"); IFilterClause fullClause = itsFilterClauseFactory.CreateCompositeFilterClause(clause1, FilterClauseCompositeOperator.OpAnd, clause2); Assert.AreEqual(fullClause.GetFilterClauseString(), filterClauseString); //---------------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() { //---------------Set up test pack------------------- IFilterClause clause1 = filterClauseFactory.CreateStringFilterClause("h a", FilterClauseOperator.OpLike, "Peter"); IFilterClause clause2 = filterClauseFactory.CreateStringFilterClause("h a", FilterClauseOperator.OpLike, "Kelly"); IFilterClause compositeClause = filterClauseFactory.CreateCompositeFilterClause(clause1, FilterClauseCompositeOperator.OpAnd, clause2); //---------------Execute Test ---------------------- string expectedFilterString = compositeClause.GetFilterClauseString("%", "'"); //---------------Test Result ----------------------- Assert.AreEqual("([h a] like '%Peter%') and ([h a] like '%Kelly%')", expectedFilterString); }
public void TestTwoCheckBoxFilter() { //---------------Set up test pack------------------- IFilterClauseFactory itsFilterClauseFactory = new DataViewFilterClauseFactory(); IFilterControl filterControl = GetControlFactory().CreateFilterControl(); filterControl.AddBooleanFilterCheckBox("Test1?", "TestColumn1", true); filterControl.AddBooleanFilterCheckBox("Test2?", "TestColumn2", false); //---------------Execute Test ---------------------- string filterClauseString = filterControl.GetFilterClause().GetFilterClauseString(); //---------------Test Result ----------------------- IFilterClause clause1 = itsFilterClauseFactory.CreateStringFilterClause("TestColumn1", FilterClauseOperator.OpEquals, "true"); IFilterClause clause2 = itsFilterClauseFactory.CreateStringFilterClause("TestColumn2", FilterClauseOperator.OpEquals, "false"); IFilterClause fullClause = itsFilterClauseFactory.CreateCompositeFilterClause(clause1, FilterClauseCompositeOperator.OpAnd, clause2); Assert.AreEqual(fullClause.GetFilterClauseString(), filterClauseString); //---------------Tear Down ------------------------- }