public void TestLoad_SingleTableInheritance_Hierarchy()
        {
            //---------------Set up test pack-------------------
            FilledCircleNoPrimaryKey.GetClassDefWithSingleInheritanceHierarchy();
            FilledCircleNoPrimaryKey filledCircle = FilledCircleNoPrimaryKey.CreateSavedFilledCircle();

            //---------------Execute Test ----------------------
            FilledCircleNoPrimaryKey loadedFilledCircle =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <FilledCircleNoPrimaryKey>(filledCircle.ID);

            //---------------Test Result -----------------------
            Assert.AreSame(filledCircle, loadedFilledCircle);
        }
 protected override void SetupInheritanceSpecifics()
 {
     ClassDef.ClassDefs.Clear();
     FilledCircleNoPrimaryKey.GetClassDefWithSingleInheritanceHierarchy();
     //_classDefShape = Shape.GetClassDef();
     //_classDefCircleNoPrimaryKey = CircleNoPrimaryKey.GetClassDef();
     //_classDefCircleNoPrimaryKey.SuperClassDef = new SuperClassDef(_classDefShape,
     //                                                              ORMapping.SingleTableInheritance);
     //_classDefCircleNoPrimaryKey.SuperClassDef.Discriminator = "ShapeType_field";
     //_classDefFilledCircleNoPrimaryKey = FilledCircleNoPrimaryKey.GetClassDef();
     //_classDefFilledCircleNoPrimaryKey.SuperClassDef = new SuperClassDef(_classDefCircleNoPrimaryKey,
     //                                                                    ORMapping.SingleTableInheritance);
     //_classDefFilledCircleNoPrimaryKey.SuperClassDef.Discriminator = "ShapeType_field";
 }
        public void TestLoad_SingleTableInheritance_Hierarchy_LoadingMiddleType_ShouldLoadSubType()
        {
            //---------------Set up test pack-------------------
            FilledCircleNoPrimaryKey.GetClassDefWithSingleInheritanceHierarchy();
            FilledCircleNoPrimaryKey filledCircle = FilledCircleNoPrimaryKey.CreateSavedFilledCircle();
            Shape shape = Shape.CreateSavedShape();
            CircleNoPrimaryKey circle = CircleNoPrimaryKey.CreateSavedCircle();

            //---------------Execute Test ----------------------
            BusinessObjectCollection <CircleNoPrimaryKey> loadedCircles =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection <CircleNoPrimaryKey>("");

            //---------------Test Result -----------------------
            Assert.AreEqual(2, loadedCircles.Count);
        }
Ejemplo n.º 4
0
        public void TestGetBusinessObject_ReturnsSubType_TwoLevelsDeep_DiscriminatorShared_Fresh()
        {
            //---------------Set up test pack-------------------
            SetupDataAccessor();

            FilledCircleNoPrimaryKey.GetClassDefWithSingleInheritanceHierarchy();
            FilledCircleNoPrimaryKey filledCircle = FilledCircleNoPrimaryKey.CreateSavedFilledCircle();

            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Execute Test ----------------------
            Shape loadedShape =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <Shape>(filledCircle.ID);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(FilledCircleNoPrimaryKey), loadedShape);
            //---------------Tear Down -------------------------
        }
Ejemplo n.º 5
0
        public void TestLoad_SingleTableInheritance_Hierarchy_Fresh()
        {
            //---------------Set up test pack-------------------
            FilledCircleNoPrimaryKey.GetClassDefWithSingleInheritanceHierarchy();
            FilledCircleNoPrimaryKey filledCircle = FilledCircleNoPrimaryKey.CreateSavedFilledCircle();

            //---------------Execute Test ----------------------
            FixtureEnvironment.ClearBusinessObjectManager();
            FilledCircleNoPrimaryKey loadedFilledCircle =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <FilledCircleNoPrimaryKey>(
                    filledCircle.ID);

            //---------------Test Result -----------------------
            Assert.AreNotSame(loadedFilledCircle, filledCircle);
            Assert.AreEqual(filledCircle.Radius, loadedFilledCircle.Radius);
            Assert.AreEqual(filledCircle.ShapeName, loadedFilledCircle.ShapeName);
            Assert.AreEqual(filledCircle.Colour, loadedFilledCircle.Colour);
            //---------------Tear Down -------------------------
        }
Ejemplo n.º 6
0
        public void TestSingleTableInheritance_TwoLevelsDeep()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            ClassDef  filledCircleClassDef         = (ClassDef)FilledCircleNoPrimaryKey.GetClassDefWithSingleInheritanceHierarchy();
            IClassDef shapeClassDef                = filledCircleClassDef.SuperClassClassDef.SuperClassClassDef;
            Criteria  expectedShapeCriteria        = new Criteria("ShapeType_field", Criteria.ComparisonOp.Is, "null");
            Criteria  expectedCircleCriteria       = new Criteria("ShapeType_field", Criteria.ComparisonOp.Equals, "CircleNoPrimaryKey");
            Criteria  expectedFilledCircleCriteria = new Criteria("ShapeType_field", Criteria.ComparisonOp.Equals, "FilledCircleNoPrimaryKey");
            Criteria  shapeOrCircleCriteria        = new Criteria(expectedShapeCriteria, Criteria.LogicalOp.Or, expectedCircleCriteria);
            Criteria  expected = new Criteria(shapeOrCircleCriteria, Criteria.LogicalOp.Or, expectedFilledCircleCriteria);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            SelectQuery selectQuery = (SelectQuery)QueryBuilder.CreateSelectQuery(shapeClassDef);

            //---------------Test Result -----------------------
            Assert.AreEqual(expected, selectQuery.DiscriminatorCriteria);
        }
Ejemplo n.º 7
0
        public void TestSingleTableInheritanceHierarchy_SharedDiscriminators()
        {
            //---------------Set up test pack-------------------
            FilledCircleNoPrimaryKey.GetClassDefWithSingleInheritanceHierarchy();
            FilledCircleNoPrimaryKey filledCircle = new FilledCircleNoPrimaryKey();
            InsertStatementGenerator gen          = new InsertStatementGenerator(filledCircle, DatabaseConnection.CurrentConnection);
            //---------------Execute Test ----------------------
            var sqlStatementCollection = gen.Generate();
            //---------------Test Result -----------------------
            var sqlStatements = sqlStatementCollection.ToList();

            Assert.AreEqual(1, sqlStatements.Count);
            ISqlStatement sqlStatement = sqlStatements[0];
            string        sql          = sqlStatement.Statement.ToString();
            int           index        = sql.IndexOf("ShapeType");

            Assert.IsTrue(index > 0);
            index = sql.IndexOf("ShapeType", index + 1);
            Assert.IsTrue(index < 0, "There were two ShapeType fields specified");
            Assert.AreEqual("FilledCircleNoPrimaryKey", sqlStatement.Parameters[4].Value);
        }