public void Test_06_ApplyToAll_TextControl() { ApplyToAllHandler handler = new ApplyToAllHandler(); IActionPropertySet actionProps = GetTestPropertySet(); ActionPropertyController controller = new ActionPropertyController(); controller.ApplyToAll += handler.HandleApplyToAll; TextBox txtPassword = new TextBox(); IActionProperty pwdProp = actionProps["Password"]; controller.Associate(txtPassword, pwdProp); txtPassword.Text = "Blue"; CheckBox cbApply_All = new CheckBox(); cbApply_All.Checked = false; IActionProperty applyProp = actionProps[ActionPropertyController.APPLY_TO_ALL]; controller.Associate(cbApply_All, applyProp); Assert.AreEqual("Blue", pwdProp.Value, "Initially we expect the property value to be false."); txtPassword.Text = "Red"; Assert.AreEqual("Red", pwdProp.Value, "After checking the box, we expect the value to be true."); Assert.AreEqual(0, handler.ApplyToAllHandled, "Do not expect to have raised the apply all event yet."); cbApply_All.Checked = true; Assert.AreEqual(0, handler.ApplyToAllHandled); controller.AssociateApplyToAll(applyProp); txtPassword.Text = "Blue"; Assert.AreEqual(1, handler.ApplyToAllHandled); cbApply_All.Checked = false; //make the property value false. txtPassword.Text = "Red"; Assert.AreEqual(1, handler.ApplyToAllHandled); cbApply_All.Checked = true; Assert.AreEqual(2, handler.ApplyToAllHandled); controller.AssociateApplyToAll(null); txtPassword.Text = "Blue"; Assert.AreEqual(2, handler.ApplyToAllHandled); }
public void Test_05_ApplyToAll_CheckBoxControl() { ApplyToAllHandler handler = new ApplyToAllHandler(); IActionPropertySet actionProps = GetTestPropertySet(); ActionPropertyController controller = new ActionPropertyController(); controller.ApplyToAll += handler.HandleApplyToAll; CheckBox cbConvert = new CheckBox(); IActionProperty convertProp = actionProps["Convert"]; controller.Associate(cbConvert,convertProp); cbConvert.Checked = false; CheckBox cbApply_All = new CheckBox(); cbApply_All.Checked = false; IActionProperty applyProp = actionProps[ActionPropertyController.APPLY_TO_ALL]; controller.Associate(cbApply_All, applyProp); Assert.AreEqual(false,(bool)convertProp.Value, "Initially we expect the property value to be false."); cbConvert.Checked = true; Assert.AreEqual(true, (bool)convertProp.Value, "After checking the box, we expect the value to be true."); Assert.AreEqual(0, handler.ApplyToAllHandled, "Do not expect to have raised the apply all event yet."); cbApply_All.Checked = true; Assert.AreEqual(0, handler.ApplyToAllHandled); controller.AssociateApplyToAll(applyProp); cbConvert.Checked = false; Assert.AreEqual(1, handler.ApplyToAllHandled); cbApply_All.Checked = false; //make the property value false. cbConvert.Checked = true; Assert.AreEqual(1, handler.ApplyToAllHandled); cbApply_All.Checked = true; Assert.AreEqual(2, handler.ApplyToAllHandled); controller.AssociateApplyToAll(null); cbConvert.Checked = false; Assert.AreEqual(2, handler.ApplyToAllHandled); }