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_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); } }
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); }
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); }