public void Test_ControlMapperStrategy_RemoveBOPropHandlers() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); MyBO.LoadDefaultClassDef(); var strategyWin = new ControlMapperStrategyWin(); var tb = _factory.CreateTextBox(); const string testprop = "TestProp"; var stubMapper = new ControlMapperStub(tb, testprop, false, _factory); var bo = new MyBO(); var prop = bo.Props[testprop]; const string origvalue = "origValue"; prop.Value = origvalue; stubMapper.BusinessObject = bo; const string newValue = "New value"; //--------------Assert PreConditions---------------- Assert.AreNotEqual(newValue, tb.Text); Assert.AreEqual(origvalue, prop.Value, "The text box value is set from the prop due to the fact that the BOPropHandler is on the ControlMapperStrategy"); Assert.AreEqual(origvalue, tb.Text, "The text box value is set from the prop due to the fact that the BOPropHandler is on the ControlMapperStrategy"); //---------------Execute Test ---------------------- strategyWin.RemoveCurrentBOPropHandlers(stubMapper, prop); prop.Value = newValue; //---------------Test Result ----------------------- Assert.AreNotEqual(newValue, tb.Text, "Updating the prop should not update the textbox since the handler has been removed"); Assert.AreEqual(origvalue, tb.Text); Assert.AreEqual(newValue, prop.Value, "The text box value is not changed when the prop has changed due the the BOPropHandler being removed"); }
public void TestEditsToOrigionalBusinessObjectDoesNotUpdateControlValue() { //---------------Set up test pack------------------- ControlMapperStub mapperStub = new ControlMapperStub (_txtNormal, "ShapeName", false, GetControlFactory()); mapperStub.BusinessObject = _shape; Assert.AreEqual("TestShapeName", _txtNormal.Text); //_shape.ShapeName = "TestShapeName"; Shape shape2 = new Shape(); shape2.ShapeName = "Shape 2 Name"; mapperStub.BusinessObject = shape2; //--------------Assert PreConditions---------------- Assert.AreEqual(shape2.ShapeName, _txtNormal.Text); //---------------Execute Test ---------------------- bool controlUpdatedFromBusinessObject = false; mapperStub.OnUpdateControlValueFromBusinessObject += delegate { controlUpdatedFromBusinessObject = true; }; _shape.ShapeName = "New original shape name"; //---------------Test Result ----------------------- Assert.IsFalse (controlUpdatedFromBusinessObject, "Control Should not have been updated when the original prop was changed."); Assert.AreEqual(shape2.ShapeName, _txtNormal.Text); }
public void Test_ControlMapperStrategy_AddBOPropHandlers() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); MyBO.LoadDefaultClassDef(); var strategyWin = new ControlMapperStrategyWin(); var factory = new Habanero.Faces.Win.ControlFactoryWin(); var tb = factory.CreateTextBox(); const string testprop = "TestProp"; var stubMapper = new ControlMapperStub(tb, testprop, false, factory); var bo = new MyBO(); var prop = bo.Props[testprop]; const string origvalue = "origValue"; prop.Value = origvalue; stubMapper.BusinessObject = bo; strategyWin.RemoveCurrentBOPropHandlers(stubMapper, prop); //--------------Assert PreConditions---------------- Assert.AreEqual(origvalue, tb.Text); //---------------Execute Test ---------------------- strategyWin.AddCurrentBOPropHandlers(stubMapper, prop); const string newValue = "New value"; prop.Value = newValue; //---------------Test Result ----------------------- Assert.AreEqual(newValue, tb.Text); }
public void Test_ControlMapperStrategy_AddBOPropHandlers() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); MyBO.LoadDefaultClassDef(); var strategyWin = new ControlMapperStrategyWin(); var factory = new Habanero.Faces.Win.ControlFactoryWin(); var tb = factory.CreateTextBox(); const string testprop = "TestProp"; var stubMapper = new ControlMapperStub(tb, testprop, false, factory); var bo = new MyBO(); var prop = bo.Props[testprop]; const string origvalue = "origValue"; prop.Value = origvalue; stubMapper.BusinessObject = bo; strategyWin.RemoveCurrentBOPropHandlers(stubMapper, prop); //--------------Assert PreConditions---------------- Assert.AreEqual(origvalue, tb.Text); //---------------Execute Test ---------------------- strategyWin.AddCurrentBOPropHandlers(stubMapper, prop); const string newValue = "New value"; prop.Value = newValue; //---------------Test Result ----------------------- Assert.AreEqual(newValue, tb.Text); }
public void TestEditsToOrigionalBusinessObjectDoesNotUpdateControlValue() { //---------------Set up test pack------------------- ControlMapperStub mapperStub = new ControlMapperStub (_txtNormal, "ShapeName", false, GetControlFactory()); mapperStub.BusinessObject = _shape; Assert.AreEqual("TestShapeName", _txtNormal.Text); //_shape.ShapeName = "TestShapeName"; Shape shape2 = new Shape(); shape2.ShapeName = "Shape 2 Name"; mapperStub.BusinessObject = shape2; //--------------Assert PreConditions---------------- Assert.AreEqual(shape2.ShapeName, _txtNormal.Text); //---------------Execute Test ---------------------- bool controlUpdatedFromBusinessObject = false; mapperStub.OnUpdateControlValueFromBusinessObject += delegate { controlUpdatedFromBusinessObject = true; }; _shape.ShapeName = "New original shape name"; //---------------Test Result ----------------------- Assert.IsFalse (controlUpdatedFromBusinessObject, "Control Should not have been updated when the original prop was changed."); Assert.AreEqual(shape2.ShapeName, _txtNormal.Text); }
public void TestNormalChangeValue_DoesNotUpdateWithoutCallingMethod() { ControlMapperStub mapperStub = new ControlMapperStub (_txtNormal, "ShapeName", false, GetControlFactory()); mapperStub.BusinessObject = _shape; Assert.AreEqual("TestShapeName", _txtNormal.Text); _shape.ShapeName = "TestShapeName2"; Assert.AreEqual("TestShapeName", _txtNormal.Text); }
public void TestNormalChangeValue() { ControlMapperStub mapperStub = new ControlMapperStub (_txtNormal, "ShapeName", false, GetControlFactory()); mapperStub.BusinessObject = _shape; Assert.AreEqual("TestShapeName", _txtNormal.Text); _shape.ShapeName = "TestShapeName2"; Assert.AreEqual("TestShapeName2", _txtNormal.Text); }
public void Test_ControlMapperStrategy_RemoveBOPropHandlers() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); MyBO.LoadDefaultClassDef(); var strategyWin = new ControlMapperStrategyWin(); var tb = _factory.CreateTextBox(); const string testprop = "TestProp"; var stubMapper = new ControlMapperStub(tb, testprop, false, _factory); var bo = new MyBO(); var prop = bo.Props[testprop]; const string origvalue = "origValue"; prop.Value = origvalue; stubMapper.BusinessObject = bo; const string newValue = "New value"; //--------------Assert PreConditions---------------- Assert.AreNotEqual(newValue, tb.Text); Assert.AreEqual(origvalue, prop.Value, "The text box value is set from the prop due to the fact that the BOPropHandler is on the ControlMapperStrategy"); Assert.AreEqual(origvalue, tb.Text, "The text box value is set from the prop due to the fact that the BOPropHandler is on the ControlMapperStrategy"); //---------------Execute Test ---------------------- strategyWin.RemoveCurrentBOPropHandlers(stubMapper, prop); prop.Value = newValue; //---------------Test Result ----------------------- Assert.AreNotEqual(newValue, tb.Text, "Updating the prop should not update the textbox since the handler has been removed"); Assert.AreEqual(origvalue, tb.Text); Assert.AreEqual(newValue, prop.Value, "The text box value is not changed when the prop has changed due the the BOPropHandler being removed"); }