Exemplo n.º 1
0
        public void TestFilterDef()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          propName     = TestUtil.GetRandomString();
            string          label        = TestUtil.GetRandomString();
            string          filterDefXml = string.Format(
                @"
                        <filter>
                            <filterProperty name=""{0}"" label=""{1}"" />
                        </filter>
	            "    , propName, label);

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

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

            Assert.IsNotNull(filterDef);
            Assert.AreEqual(1, filterDef.FilterPropertyDefs.Count);
            Assert.AreEqual(propName, filterDef.FilterPropertyDefs[0].PropertyName);
            Assert.AreEqual(label, filterDef.FilterPropertyDefs[0].Label);
            Assert.AreEqual("StringTextBoxFilter", filterDef.FilterPropertyDefs[0].FilterType);
            Assert.AreEqual("Habanero.Faces.Base", filterDef.FilterPropertyDefs[0].FilterTypeAssembly);
            Assert.AreEqual(FilterClauseOperator.OpLike, filterDef.FilterPropertyDefs[0].FilterClauseOperator);
            Assert.AreEqual(0, filterDef.FilterPropertyDefs[0].Parameters.Count);
            Assert.AreEqual(FilterModes.Filter, filterDef.FilterMode);
            Assert.AreEqual(0, filterDef.Columns);


            //---------------Tear Down -------------------------
        }
Exemplo n.º 2
0
        public void TestFilterDefWithParameters()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          paramName    = TestUtil.GetRandomString();
            string          paramValue   = TestUtil.GetRandomString();
            string          filterDefXml = string.Format(
                @"
                        <filter>
                            <filterProperty name=""prop1"" label=""label1"" />
                            <filterProperty name=""prop2"" label=""label2"" >
                                <parameter name=""{0}"" value=""{1}"" />
                            </filterProperty>
                        </filter>
	            "    , paramName, paramValue);

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.IsNotNull(filterDef);
            Assert.AreEqual(2, filterDef.FilterPropertyDefs.Count);
            Assert.AreEqual(1, filterDef.FilterPropertyDefs[1].Parameters.Count);
            Assert.IsTrue(filterDef.FilterPropertyDefs[1].Parameters.ContainsKey(paramName));
            Assert.AreEqual(paramValue, filterDef.FilterPropertyDefs[1].Parameters[paramName]);

            //---------------Tear Down -------------------------
        }
Exemplo n.º 3
0
        public void Test_Invalid_NoProperties()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            const string    filterDefXml = @"<filter />";

            //---------------Execute Test ----------------------
            try
            {
                IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);
                Assert.Fail("An error should have occurred because a filter requires at least on filterProperty.");

                //---------------Test Result -----------------------
            }
            catch (InvalidXmlDefinitionException ex)
            {
                StringAssert.Contains("The 'filter' node does not conform", ex.Message);
            }
        }
Exemplo n.º 4
0
        public void TestFilterClauseOperator()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          filterDefXml =
                @"
                        <filter>
                            <filterProperty name=""prop1"" label=""label1"" operator=""OpEquals""/>
                        </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.AreEqual(FilterClauseOperator.OpEquals, filterDef.FilterPropertyDefs[0].FilterClauseOperator);

            //---------------Tear Down -------------------------
        }
Exemplo n.º 5
0
        public void TestColumns()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          filterDefXml =
                @"
                        <filter columns=""3"">
                            <filterProperty name=""prop1"" label=""label1"" />
                        </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.AreEqual(3, filterDef.Columns);

            //---------------Tear Down -------------------------
        }
Exemplo n.º 6
0
        public void TestFilterMode_Search()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          filterDefXml =
                @"
                        <filter filterMode=""Search"">
                            <filterProperty name=""prop1"" label=""label1"" />
                        </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

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

            Assert.AreEqual(FilterModes.Search, filterDef.FilterMode);
            //---------------Tear Down -------------------------
        }
Exemplo n.º 7
0
        public void TestFilterDef_AlternateFormat()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            const string    filterDefXml = @"
                            <filter>
			                    <filterProperty name=""name""  label=""label"" >
			                    </filterProperty>
			                </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.IsNotNull(filterDef);
            Assert.AreEqual(1, filterDef.FilterPropertyDefs.Count);
            //---------------Tear Down -------------------------
        }