public void Test_08_Associate_NonSupportedControl() { MockActionProperty prop = new MockActionProperty("SomeProperty", typeof(bool), PropertyDisplayType.Checkbox, true, true); ActionPropertyController controller = new ActionPropertyController(); Button button = new Button(); bool bCatch = false; try { controller.Associate( button, prop); } catch(Exception) { bCatch = true; } Assert.IsTrue(bCatch, "Expected to catch an exception when passing in an unsuitable control."); bCatch = false; try { controller.AssociateValidator(button, prop); } catch (Exception) { bCatch = true; } Assert.IsTrue(bCatch, "Expected to catch an exception when passing in an unsuitable control."); }
private IActionPropertySet GetTestPropertySet() { ActionPropertySet properties = new ActionPropertySet(); properties.Add("Convert", new MockActionProperty("Convert to PDF", typeof(bool), PropertyDisplayType.Checkbox, true, true)); properties.Add("Security", new MockActionProperty("Make PDF secure", typeof(bool), PropertyDisplayType.Checkbox, false, true)); MockActionProperty invisibleProp = new MockActionProperty("Invisible", typeof(bool), PropertyDisplayType.Checkbox, true, true); invisibleProp.Visible = false; properties.Add("Invisible", invisibleProp); properties.Add("Password", new MockActionProperty("Password", typeof(string), PropertyDisplayType.TextBox, "", true)); properties.Add(ActionPropertyController.APPLY_TO_ALL, new MockActionProperty(ActionPropertyController.APPLY_TO_ALL, typeof(bool), PropertyDisplayType.Checkbox, false, false)); properties.Add("ExcludeStuff", new MockActionProperty("Exclude Stuff", typeof(bool), PropertyDisplayType.Checkbox, true, true)); properties.Add("CustomProperties", new MockActionProperty("Custom Properties", typeof(string), PropertyDisplayType.TextBox, "", true)); return properties; }
public void Test_07_Associate_NonOverridableProperty() { MockActionProperty prop = new MockActionProperty("IAmNotOverridableByTheUser", typeof (bool), PropertyDisplayType.Checkbox, true, true); prop.Override = false; CheckBox checkBox = new CheckBox(); checkBox.Enabled = true; ActionPropertyController controller = new ActionPropertyController(); controller.Associate(checkBox, prop); Assert.IsFalse( checkBox.Enabled, "If the property is read-only it is not overridable, so the checkbox should be disabled."); controller = new ActionPropertyController(); TextBox validationControl = new TextBox(); checkBox.Enabled = true; controller.AssociateValidator(validationControl, prop); Assert.IsFalse(validationControl.Enabled, "If the property is read-only it is not overridable, so the checkbox should be disabled."); }