Exemplo n.º 1
0
        public override void SetValue(object component, object value)
        {
            IBusinessObject bo       = GetBusinessObject(component);
            BOMapper        boMapper = new BOMapper(bo);

            boMapper.SetDisplayPropertyValue(PropertyName, value);
        }
Exemplo n.º 2
0
        public void Test_SetDisplayPropertyValue_WithRelatedPropName_ShouldSetPropValue()
        {
            //---------------Set up test pack-------------------
            const string underlyingPropName = "MyRelatedTestProp";
            const string propName           = "MyRelationship." + underlyingPropName;

            ClassDef.ClassDefs.Clear();

            var myBOClassDef    = MyBO.LoadClassDefWithRelationship();
            var relatedClassDef = MyRelatedBo.LoadClassDef();

            MyBO        myBO        = (MyBO)myBOClassDef.CreateNewBusinessObject();
            MyRelatedBo myRelatedBo = (MyRelatedBo)relatedClassDef.CreateNewBusinessObject();

            myBO.Relationships.SetRelatedObject("MyRelationship", myRelatedBo);
            BOMapper boMapper         = new BOMapper(myBO);
            var      initialPropValue = RandomValueGen.GetRandomString();

            myRelatedBo.SetPropertyValue(underlyingPropName, initialPropValue);
            //---------------Assert Precondition----------------
            Assert.AreEqual(initialPropValue, myRelatedBo.GetPropertyValue(underlyingPropName));
            //---------------Execute Test ----------------------
            var expectedPropValue = RandomValueGen.GetRandomString();

            boMapper.SetDisplayPropertyValue(propName, expectedPropValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedPropValue, myRelatedBo.GetPropertyValue(underlyingPropName));
        }
Exemplo n.º 3
0
        public void Test_SetPropertyDisplayValue_WithIntString_ShouldBeAbleGetString()
        {
            //---------------Set up test pack-------------------

            ClassDef.ClassDefs.Clear();
            MyBO.LoadDefaultClassDef();
            var          testBo   = new MyBO();
            var          boMapper = new BOMapper(testBo);
            const string propName = "TestProp";

            boMapper.SetDisplayPropertyValue(propName, "7");
            //---------------Assert Precondition----------------
            Assert.AreEqual("7", boMapper.GetPropertyValueToDisplay(propName).ToString());
            //---------------Execute Test ----------------------
            boMapper.SetDisplayPropertyValue(propName, "3");
            //---------------Test Result -----------------------
            Assert.AreEqual("3", boMapper.GetPropertyValueToDisplay(propName).ToString());
            Assert.AreEqual("3", testBo.TestProp);
        }
Exemplo n.º 4
0
        public void Test_SetDisplayPropertyValue_WhenLookupList_ShouldSetUnderlyingValue()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            const string propertyName = "TestProp2";
            const string expectedLookupDisplayValue = "s1";
            Guid         expectedLookupValue;

            StringUtilities.GuidTryParse("{E6E8DC44-59EA-4e24-8D53-4A43DC2F25E7}", out expectedLookupValue);
            _itsClassDef = MyBO.LoadClassDefWithLookup();
            MyBO     bo1      = (MyBO)_itsClassDef.CreateNewBusinessObject();
            BOMapper boMapper = new BOMapper(bo1);

            //---------------Assert Precondition----------------
            Assert.IsNullOrEmpty(bo1.TestProp2);
            //---------------Execute Test ----------------------
            boMapper.SetDisplayPropertyValue(propertyName, expectedLookupDisplayValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedLookupValue, bo1.GetPropertyValue(propertyName));
            Assert.AreEqual(expectedLookupDisplayValue, bo1.GetPropertyValueToDisplay(propertyName));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sets the property value to that provided.  If the property value
        /// is invalid, the error provider will be given the reason why the
        /// value is invalid.
        /// </summary>
        protected virtual void SetPropertyValue(object value)
        {
            if (_businessObject == null)
            {
                return;
            }
            var boMapper = new BOMapper(_businessObject);

            try
            {
                boMapper.SetDisplayPropertyValue(PropertyName, value);
            }
            catch (InvalidPropertyValueException ex)
            {
                SetError(ex.Message);
                return;
            }
            catch (HabaneroIncorrectTypeException ex)
            {
                SetError(ex.Message);
                return;
            }
            UpdateErrorProviderErrorMessage();
        }