public AddClickEventHandler ( |
||
mapper | The checkbox mapper | |
return | void |
public void AddClickEventHandler(CheckBoxMapper mapper)
{
var checkBox = mapper.GetControl() as CheckBox;
if (checkBox == null) return;
checkBox.CheckedChanged += delegate
{
try
{
mapper.ApplyChangesToBusinessObject();
mapper.UpdateControlValueFromBusinessObject();
}
catch (Exception ex)
{
GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
}
};
}
}
public void Test_AddClickEventHandler_WhenMapperUsingControlAdapter_ShouldAddBehaviours() { //---------------Set up test pack------------------- var checkBoxWin = GetWinFormsControlAdapter(); DisposeOnTearDown(checkBoxWin); var checkBoxMapper = new CheckBoxMapperStub(checkBoxWin); //---------------Assert Precondition---------------- Assert.IsInstanceOf<CheckBox>(checkBoxMapper.GetControl()); //---------------Execute Test ---------------------- var checkBoxStrategyWin = new CheckBoxStrategyWin(); checkBoxStrategyWin.AddClickEventHandler(checkBoxMapper); //---------------Assert Result---------------------- Assert.IsTrue(true, "If an error was not thrown then we are OK"); }