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 TestNormalChangeBO_DoesNotUpdateWithoutCallingMethod()
 {
     _normalMapper.BusinessObject = _shape;
     Assert.AreEqual("TestShapeName", _txtNormal.Text);
     Shape shape2 = new Shape();
     shape2.ShapeName = "Different";
     _normalMapper.BusinessObject = shape2;
     Assert.AreEqual("Different", _txtNormal.Text);
     shape2.ShapeName = "Different2";
     Assert.AreEqual("Different", _txtNormal.Text);
 }
 public void TestSettingToAnotherBusinessObject()
 {
     _shape.ShapeName = "TestShapeName";
     _mapper.BusinessObject = _shape;
     Shape sh2 = new Shape();
     sh2.ShapeName = "Different";
     _mapper.BusinessObject = sh2;
     Assert.AreEqual("Different", _textBox.Text, "Setting to another bo doesn't work.");
     _shape.ShapeName = "TestShapeName2";
     Assert.AreEqual("Different", _textBox.Text,
                     "Setting to another bo doesn't remove the property updating event handler of the first.");
 }
 public void TestNormalChangeBO()
 {
     _normalMapper.BusinessObject = _shape;
     Assert.AreEqual("TestShapeName", _txtNormal.Text);
     Shape shape2 = new Shape();
     shape2.ShapeName = "Different";
     _normalMapper.BusinessObject = shape2;
     Assert.AreEqual("Different", _txtNormal.Text);
     shape2.ShapeName = "Different2";
     _normalMapper.UpdateControlValueFromBusinessObject();
     Assert.AreEqual("Different2", _txtNormal.Text);
 }
 public void SetupTest()
 {
     _textBox = GetControlFactory().CreateTextBox();
     _mapper = new TextBoxMapper(_textBox,  "ShapeName", false, GetControlFactory());
     _shape = new Shape();
 }
예제 #6
0
 public static Shape CreateSavedShape()
 {
     Shape shape = new Shape();
     shape.ShapeName = TestUtil.GetRandomString();
     shape.Save();
     return shape;
 }