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.");

        }
		public void Test_04_AssociateValidator()
		{
			IActionPropertySet actionProps = GetTestPropertySet();
			ActionPropertyController controller = new ActionPropertyController();

			TextBox edPassword = new TextBox();
			TextBox edValidator = new TextBox();

			IActionProperty propPassword1 = actionProps["Password"];

			controller.Associate(edPassword, propPassword1);
			controller.AssociateValidator(edValidator, propPassword1);

			Assert.AreEqual("", edPassword.Text, "The password is not set to start with");
			Assert.AreEqual("", edValidator.Text, "The password is not set to start with");

			edPassword.Text = "Hello";

			Assert.AreEqual("Hello", edPassword.Text, "The password is set but not validated");
			Assert.AreEqual("", edValidator.Text, "The password is set but not validated");
			Assert.AreEqual("", Convert.ToString(propPassword1.Value), "The password is set but not validated");

			edValidator.Text = "Hello";
			Assert.AreEqual("Hello", edPassword.Text, "The password is now validated");
			Assert.AreEqual("Hello", edValidator.Text, "The password is now validated");
			Assert.AreEqual("Hello", Convert.ToString(propPassword1.Value), "The password is now validated");

			edPassword.Text = "Hello2";
			Assert.AreEqual("Hello2", edPassword.Text, "The password has been invalidated");
			Assert.AreEqual("Hello", edValidator.Text, "The password has been invalidated");
			Assert.AreEqual("", Convert.ToString(propPassword1.Value), "The password has been invalidated");

			edValidator.Text = "Hello2";
			Assert.AreEqual("Hello2", edPassword.Text, "The password has been re-validated");
			Assert.AreEqual("Hello2", edValidator.Text, "The password has been re-validated");
			Assert.AreEqual("Hello2", Convert.ToString(propPassword1.Value), "The password has been re-validated");
		}
        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.");
        }