Пример #1
0
        public void TestAddMulitplePropStringFilterTextBox()
        {
            //---------------Set up test pack-------------------
            IFilterClause  nullClause    = new DataViewNullFilterClause();
            IFilterControl filterControl = GetControlFactory().CreateFilterControl();
            //---------------Execute Test ----------------------
            List <string> props = new List <string> {
                "TestColumn"
            };
            ITextBox tb = filterControl.AddMultiplePropStringTextBox("Test:", props);

            tb.Text = "";
            //---------------Test Result -----------------------
            Assert.AreEqual(nullClause.GetFilterClauseString(), filterControl.GetFilterClause().GetFilterClauseString());
            Assert.AreEqual(1, filterControl.FilterControls.Count);
            //---------------Tear Down -------------------------
        }
        public void Test_WithAddMultiplePropStringTextBoxFilterClause_WhenTextBoxValueChanged_ShouldApplyFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();
            ITextBox        textBox = ctl.AddMultiplePropStringTextBox("test", new List <string>()
            {
                "propname", "propname2"
            }, FilterClauseOperator.OpEquals);
            string text = TestUtil.GetRandomString();

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            textBox.Text = text;
            //---------------Test Result -----------------------
            Assert.IsTrue(filterFired, "The filter event should have been fired when the text was changed.");
        }
Пример #3
0
        public void TestGetMultiplePropTextBoxFilterClause_Equals()
        {
            //---------------Set up test pack-------------------
            IFilterClauseFactory itsFilterClauseFactory = new DataViewFilterClauseFactory();
            IFilterControl       filterControl          = GetControlFactory().CreateFilterControl();
            ITextBox             tb = filterControl.AddMultiplePropStringTextBox("Test:", new List <string> {
                "TestColumn"
            }, FilterClauseOperator.OpEquals);

            //---------------Execute Test ----------------------
            tb.Text = "testvalue";
            string filterClauseString = filterControl.GetFilterClause().GetFilterClauseString();

            //---------------Test Result -----------------------
            IFilterClause clause =
                itsFilterClauseFactory.CreateStringFilterClause("TestColumn", FilterClauseOperator.OpEquals, "testvalue");

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

            //---------------Tear Down -------------------------
        }
        public void Test_WithAddMultiplePropStringTextBox_WhenTextBoxValueChanged_AndInSearchMode_ShouldNotApplyFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();

            ctl.FilterMode = FilterModes.Search;
            ITextBox textBox = ctl.AddMultiplePropStringTextBox("test", new List <string>()
            {
                "propname", "propname2"
            });
            string text = TestUtil.GetRandomString();

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.AreEqual(FilterModes.Search, ctl.FilterMode);
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            textBox.Text = text;
            //---------------Test Result -----------------------
            Assert.IsFalse(filterFired, "The filter event should not have been fired when the text was changed.");
        }