Beispiel #1
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));
        }
        public void TestSetRelatedBusinessObject()
        {
            //---------------Set up test pack-------------------
            IClassDef   classDef        = MyBO.LoadClassDefWithRelationship();
            IClassDef   relatedClassDef = MyRelatedBo.LoadClassDef();
            MyBO        bo1             = (MyBO)classDef.CreateNewBusinessObject();
            MyRelatedBo relatedBo1      = (MyRelatedBo)relatedClassDef.CreateNewBusinessObject();

            //---------------Execute Test ----------------------
            bo1.Relationships.SetRelatedObject("MyRelationship", relatedBo1);

            //---------------Test Result -----------------------
            Assert.AreSame(relatedBo1, bo1.Relationships.GetRelatedObject <MyRelatedBo>("MyRelationship"));
            Assert.AreSame(bo1.GetPropertyValue("RelatedID"), relatedBo1.GetPropertyValue("MyRelatedBoID"));
        }