Ejemplo n.º 1
0
        public void TestLoadingRelatedObjectWithSingleTableInheritance()
        {
            //---------------Set up test pack-------------------
            DatabaseConnection.CurrentConnection.ExecuteRawSql(
                "delete from filledcircle_table; delete from circle_table; delete from shape_table");
            //MyBO has a relationship to Shape. Shape potentially has a circle for single table inheritance.
            MyBO.LoadClassDefWithShape_SingleTableInheritance_Relationship();

            MyBO bo = new MyBO();
            CircleNoPrimaryKey circle = new CircleNoPrimaryKey();

            circle.Radius    = 5;
            circle.ShapeName = "MyShape";
            circle.Save();
            bo.SetPropertyValue("ShapeID", circle.ShapeID);
            bo.Save();

            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Execute Test ----------------------
            bo = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <MyBO>(bo.ID);
            Shape shape = bo.Shape;

            //---------------Test Result -----------------------
            Assert.AreSame(typeof(CircleNoPrimaryKey), shape.GetType());
            Assert.IsFalse(shape.Status.IsNew);
            Assert.IsFalse(shape.Status.IsDeleted);
            Assert.IsFalse(shape.Status.IsEditing);
            Assert.IsFalse(shape.Status.IsDirty);
            Assert.IsTrue(shape.Status.IsValid());
        }