Example #1
0
        public override object GetValue(object component)
        {
            IBusinessObject bo       = GetBusinessObject(component);
            BOMapper        boMapper = new BOMapper(bo);

            return(boMapper.GetPropertyValueToDisplay(PropertyName));
        }
Example #2
0
 /// <summary>
 /// Returns the property value of the business object being mapped
 /// </summary>
 /// <returns>Returns the property value in appropriate object form</returns>
 protected virtual object GetPropertyValue()
 {
     if (_businessObject != null)
     {
         var boMapper = new BOMapper(_businessObject);
         return(boMapper.GetPropertyValueToDisplay(PropertyName));
     }
     return(null);
 }
Example #3
0
        public void Test_GetPropertyValueToDisplay_WhenVirtualPropertyValue()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef = MyBO.LoadDefaultClassDef();
            MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();

            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("MyNameIsMyBo", mapper.GetPropertyValueToDisplay("-MyName-"));
        }
Example #4
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);
        }
Example #5
0
        public void Test_GetPropertyValueToDisplay_SimpleLookup()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef = MyBO.LoadClassDefWithSimpleIntegerLookup();
            MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();

            bo1.SetPropertyValue("TestProp2", "Text");
            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("Text", mapper.GetPropertyValueToDisplay("TestProp2"));
        }
Example #6
0
        public void Test_GetPropertyValue_WithDot()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef        = MyBO.LoadClassDefWithRelationship();
            _itsRelatedClassDef = MyRelatedBo.LoadClassDef();
            //MyBO bo1 = (MyBO)itsClassDef.CreateNewBusinessObject(connection);
            MyBO        bo1             = (MyBO)_itsClassDef.CreateNewBusinessObject();
            MyRelatedBo relatedBo       = (MyRelatedBo)_itsRelatedClassDef.CreateNewBusinessObject();
            Guid        myRelatedBoGuid = relatedBo.ID.GetAsGuid();

            bo1.SetPropertyValue("RelatedID", myRelatedBoGuid);
            relatedBo.SetPropertyValue("MyRelatedTestProp", "MyValue");
            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("MyValue", mapper.GetPropertyValueToDisplay("MyRelationship.MyRelatedTestProp"));
        }
Example #7
0
        public void Test_GetPropertyValue_WithDot_IncorrectRelationshipName()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            _itsClassDef        = MyBO.LoadClassDefWithRelationship();
            _itsRelatedClassDef = MyRelatedBo.LoadClassDef();
            MyBO     bo1    = (MyBO)_itsClassDef.CreateNewBusinessObject();
            BOMapper mapper = new BOMapper(bo1);

            //---------------Execute Test ----------------------
            try
            {
                mapper.GetPropertyValueToDisplay("MyIncorrectRelationship.MyRelatedTestProp");
                Assert.Fail("Expected to throw an RelationshipNotFoundException");
            }
            //---------------Test Result -----------------------
            catch (RelationshipNotFoundException ex)
            {
                StringAssert.Contains("The relationship 'MyIncorrectRelationship' on 'MyBO' cannot be found", ex.Message);
            }
        }