public void TestDisplayingRelatedProperty() { SetupClassDefs("MyValue"); _mapper = new TextBoxMapper(_textBox, "MyRelationship.MyRelatedTestProp", true, GetControlFactory()); _mapper.BusinessObject = itsMyBo; Assert.AreEqual("MyValue", _textBox.Text); }
protected PanelInfo.FieldInfo CreateFieldInfo(string propertyName) { ILabel label = GetControlFactory().CreateLabel(); ITextBox tb = GetControlFactory().CreateTextBox(); IControlMapper controlMapper = new TextBoxMapper(tb, propertyName, false, GetControlFactory()); GetControlFactory().CreateErrorProvider(); return(new PanelInfo.FieldInfo(propertyName, label, controlMapper)); }
/// <summary> /// Adds key press event handlers that carry out actions like /// limiting the input of certain characters, depending on the type of the /// property /// </summary> /// <param name="mapper">The TextBox mapper</param> /// <param name="boProp">The property being mapped</param> public void AddKeyPressEventHandler(TextBoxMapper mapper, IBOProp boProp) { BoProp = boProp; var tb = mapper.GetControl() as TextBox; if (tb != null) { tb.KeyPress += KeyPressEventHandler; TextBoxControl = tb; } }
public void AddUpdateBoPropOnTextChangedHandler(TextBoxMapper mapper, IBOProp boProp) { BoProp = boProp; _mapper = mapper; var tb = mapper.GetControl() as TextBox; if (tb != null) { tb.TextChanged += UpdateBoPropWithTextFromTextBox; TextBoxControl = tb; } }
public void Test_SetBusinessObject_ShouldSetBusinessObject() { //---------------Set up test pack------------------- var mapper = new TextBoxMapper(new WinFormsTextBoxAdapter(GenerateStub <TextBox>()), "FakeStringProp", false, new ControlFactoryWin()); var expectedBO = new FakeBo(); //---------------Assert Precondition---------------- Assert.IsNotNull(expectedBO); Assert.AreNotSame(expectedBO, mapper.BusinessObject); //---------------Execute Test ---------------------- mapper.BusinessObject = expectedBO; //---------------Test Result ----------------------- Assert.AreSame(expectedBO, mapper.BusinessObject); }
public void TestFieldInfo_Constructor() { //---------------Set up test pack------------------- ILabel label = GetControlFactory().CreateLabel(); string propertyName = TestUtil.GetRandomString(); ITextBox tb = GetControlFactory().CreateTextBox(); IControlMapper controlMapper = new TextBoxMapper(tb, propertyName, false, GetControlFactory()); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- PanelInfo.FieldInfo fieldInfo = new PanelInfo.FieldInfo(propertyName, label, controlMapper); //---------------Test Result ----------------------- Assert.AreEqual(propertyName, fieldInfo.PropertyName); Assert.AreSame(label, fieldInfo.LabelControl); Assert.AreSame(controlMapper, fieldInfo.ControlMapper); Assert.AreSame(tb, fieldInfo.InputControl); }
public void Test_MapperStrategy_Returns_Correct_BoProp_WhenChangingBOs() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); MyBO.LoadClassDefWithIntegerRule(); MyBO myBo = new MyBO(); _mapper = new TextBoxMapper(_textBox, "TestProp2", false, GetControlFactory()); _mapper.BusinessObject = myBo; _textBox.Name = "TestTextBox"; //---------------Assert pre-conditions-------------- Assert.AreEqual(_mapper.CurrentBOProp(), ((TextBoxMapperStrategyWin)_mapper.TextBoxMapperStrategy).BoProp); Assert.AreEqual(_mapper.Control, ((TextBoxMapperStrategyWin)_mapper.TextBoxMapperStrategy).TextBoxControl); //---------------Execute Test ---------------------- ClassDef.ClassDefs.Clear(); MyBO.LoadDefaultClassDef(); MyBO myNewBo = new MyBO(); _mapper.BusinessObject = myNewBo; //---------------Test Result ----------------------- Assert.AreEqual(_mapper.CurrentBOProp(), ((TextBoxMapperStrategyWin)_mapper.TextBoxMapperStrategy).BoProp); //---------------Tear down ------------------------- }
public void SetupTest() { _textBox = GetControlFactory().CreateTextBox(); _mapper = new TextBoxMapper(_textBox, "ShapeName", false, GetControlFactory()); _shape = new Shape(); }