public void Test_BuildCustomFilter_SetParametersViaReflection_InvalidProperty()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder           = new FilterControlBuilder(GetControlFactory());
            string parameterName                   = TestUtil.GetRandomString();
            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                { parameterName, TestUtil.GetRandomString() }
            };

            string            propertyName      = TestUtil.GetRandomString();
            const string      filterType        = "BoolCheckBoxFilter";
            FilterPropertyDef filterPropertyDef = new FilterPropertyDef
                                                      (propertyName, TestUtil.GetRandomString(), filterType, "", FilterClauseOperator.OpEquals, parameters);

            //---------------Execute Test ----------------------
            try
            {
                builder.BuildCustomFilter(filterPropertyDef);
                Assert.Fail("Error should have occured because a parameter didn't exist.");

                //---------------Test Result -----------------------
            }
            catch (HabaneroDeveloperException ex)
            {
                StringAssert.Contains
                    (string.Format
                        ("The property '{0}' was not found on a filter of type '{1}' for property '{2}'", parameterName,
                        filterType, propertyName), ex.Message);
            }
        }
        private static FilterDef CreateFilterDef_3Properties()
        {
            FilterPropertyDef filterPropertyDef1 = CreateFilterPropertyDef();
            FilterPropertyDef filterPropertyDef2 = CreateFilterPropertyDef();
            FilterPropertyDef filterPropertyDef3 = CreateFilterPropertyDef();

            return(new FilterDef
                       (new List <IFilterPropertyDef> {
                filterPropertyDef1, filterPropertyDef2, filterPropertyDef3
            }));
        }
        public void Test_BuildCustomFilter_CustomAssembly()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());

            FilterPropertyDef filterPropertyDef1 = CreateFilterPropertyDefWithType
                                                       ("Habanero.Faces.Test.Base.FilterController.SimpleFilterStub", "Habanero.Faces.Test.Base");
            //---------------Execute Test ----------------------
            ICustomFilter customFilter = builder.BuildCustomFilter(filterPropertyDef1);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(SimpleFilterStub), customFilter);
        }
        public void Test_BuildCustomFilter_FilterClauseOperator()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());

            const FilterClauseOperator op = FilterClauseOperator.OpLessThanOrEqualTo;
            FilterPropertyDef          filterPropertyDef1 = CreateFilterPropertyDef(op);

            //---------------Execute Test ----------------------
            ICustomFilter customFilter = builder.BuildCustomFilter(filterPropertyDef1);

            //---------------Test Result -----------------------
            Assert.AreEqual(op, customFilter.FilterClauseOperator);
        }
Exemple #5
0
        public void Test_Constructor_WithStringParameters()
        {
            //---------------Set up test pack-------------------
            string propName           = TestUtil.GetRandomString();
            string label              = TestUtil.GetRandomString();
            string filterType         = TestUtil.GetRandomString();
            string filterTypeAssembly = TestUtil.GetRandomString();
            FilterClauseOperator        filterClauseOperator = TestUtil.GetRandomEnum <FilterClauseOperator>();
            Dictionary <string, string> parameters           = new Dictionary <string, string>();
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            FilterPropertyDef def = new FilterPropertyDef(propName, label, filterType, filterTypeAssembly, filterClauseOperator, parameters);

            //---------------Test Result -----------------------
            Assert.AreEqual(propName, def.PropertyName);
            Assert.AreEqual(label, def.Label);
            Assert.AreEqual(filterType, def.FilterType);
            Assert.AreEqual(filterTypeAssembly, def.FilterTypeAssembly);
            Assert.AreSame(parameters, def.Parameters);
            Assert.AreEqual(filterClauseOperator, def.FilterClauseOperator);
        }
        public void Test_BuildCustomFilter_SetParametersViaReflection()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());

            Dictionary <string, string> parameters = new Dictionary <string, string> {
                { "IsChecked", "true" }
            };

            FilterPropertyDef filterPropertyDef = new FilterPropertyDef
                                                      (TestUtil.GetRandomString(), TestUtil.GetRandomString(), "BoolCheckBoxFilter", "",
                                                      FilterClauseOperator.OpEquals, parameters);
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            ICustomFilter customFilter = builder.BuildCustomFilter(filterPropertyDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(BoolCheckBoxFilter), customFilter);
            BoolCheckBoxFilter checkBoxFilter = (BoolCheckBoxFilter)customFilter;

            Assert.IsTrue(checkBoxFilter.IsChecked);
        }
Exemple #7
0
        public void Test_Constructor_WithTypeParameters()
        {
            //---------------Set up test pack-------------------
            string propName = TestUtil.GetRandomString();
            string label    = TestUtil.GetRandomString();
            Dictionary <string, string> parameters           = new Dictionary <string, string>();
            FilterClauseOperator        filterClauseOperator = TestUtil.GetRandomEnum <FilterClauseOperator>();
            Type filterType = typeof(MyFilterType);
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            FilterPropertyDef def = new FilterPropertyDef(propName, label, filterType, filterClauseOperator, parameters);

            //---------------Test Result -----------------------
            Assert.AreEqual(propName, def.PropertyName);
            Assert.AreEqual(label, def.Label);
            string assemblyName;
            string classNameFull;

            TypeLoader.ClassTypeInfo(filterType, out assemblyName, out classNameFull);
            Assert.AreEqual(classNameFull, def.FilterType);
            Assert.AreEqual(assemblyName, def.FilterTypeAssembly);
            Assert.AreSame(parameters, def.Parameters);
            Assert.AreEqual(filterClauseOperator, def.FilterClauseOperator);
        }