public void TestLoad_SingleTableInheritance()
        {
            //---------------Set up test pack-------------------
            CircleNoPrimaryKey.GetClassDefWithSingleInheritance();
            CircleNoPrimaryKey circle = CircleNoPrimaryKey.CreateSavedCircle();

            //---------------Execute Test ----------------------
            CircleNoPrimaryKey loadedCircle =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <CircleNoPrimaryKey>(circle.ID);

            //---------------Test Result -----------------------

            Assert.AreSame(circle, loadedCircle);
        }
        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);
        }
Esempio n. 3
0
        public void TestGetBusinessObject_ReturnsSubType_Fresh()
        {
            //---------------Set up test pack-------------------
            SetupDataAccessor();

            CircleNoPrimaryKey.GetClassDefWithSingleInheritance();
            CircleNoPrimaryKey circle = CircleNoPrimaryKey.CreateSavedCircle();

            FixtureEnvironment.ClearBusinessObjectManager();

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

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CircleNoPrimaryKey), loadedShape);
        }
Esempio n. 4
0
        public void TestLoad_SingleTableInheritance_Fresh()
        {
            //---------------Set up test pack-------------------
            CircleNoPrimaryKey.GetClassDefWithSingleInheritance();
            CircleNoPrimaryKey circle = CircleNoPrimaryKey.CreateSavedCircle();

            //---------------Execute Test ----------------------
            FixtureEnvironment.ClearBusinessObjectManager();
            CircleNoPrimaryKey loadedCircle =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <CircleNoPrimaryKey>(circle.ID);

            //---------------Test Result -----------------------
            Assert.AreNotSame(loadedCircle, circle);
            Assert.AreEqual(circle.Radius, loadedCircle.Radius);
            Assert.AreEqual(circle.ShapeName, loadedCircle.ShapeName);
        }
        public void Test_GetBusinessObjectCollection_Generic_ReturnsSubType_NonFresh()
        {
            //---------------Set up test pack-------------------
            CircleNoPrimaryKey.GetClassDefWithSingleInheritance();
            CircleNoPrimaryKey circle   = CircleNoPrimaryKey.CreateSavedCircle();
            Criteria           criteria = Criteria.FromPrimaryKey(circle.ID);

            //---------------Execute Test ----------------------
            BusinessObjectCollection <Shape> loadedShapes =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection <Shape>(criteria);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, loadedShapes.Count);
            Shape loadedShape = loadedShapes[0];

            Assert.IsInstanceOf(typeof(CircleNoPrimaryKey), loadedShape);
            Assert.AreSame(circle, loadedShape);
        }
        public void Test_GetBusinessObjectCollection_NonGeneric_ReturnsSubType_Fresh()
        {
            //---------------Set up test pack-------------------
            CircleNoPrimaryKey.GetClassDefWithSingleInheritance();
            CircleNoPrimaryKey circle   = CircleNoPrimaryKey.CreateSavedCircle();
            Criteria           criteria = Criteria.FromPrimaryKey(circle.ID);

            FixtureEnvironment.ClearBusinessObjectManager();

            IClassDef classDef = ClassDef.Get <Shape>();
            //---------------Execute Test ----------------------
            IBusinessObjectCollection loadedShapes =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection(classDef, criteria);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, loadedShapes.Count);
            Assert.IsInstanceOf(typeof(Shape), loadedShapes[0]);
            Shape loadedShape = (Shape)loadedShapes[0];

            Assert.IsInstanceOf(typeof(CircleNoPrimaryKey), loadedShape);
            Assert.IsInstanceOf(typeof(BusinessObjectCollection <Shape>), loadedShapes);
        }
Esempio n. 7
0
        public void TestLoad_SingleTableInheritance__GetBOAsParent_ThenGetBOAsShape_ThenGetAsCircle_ShouldLoadCircle()
        {
            //---------------Set up test pack-------------------
            CircleNoPrimaryKey.GetClassDefWithSingleInheritance();
            CircleNoPrimaryKey circle = CircleNoPrimaryKey.CreateSavedCircle();

            FixtureEnvironment.ClearBusinessObjectManager();
            //---------------Assert Preconditions---------------
            //---------------Execute Test ----------------------
            Shape circleLoadedAsShape       = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <Shape>("ShapeID = " + circle.ShapeID);
            CircleNoPrimaryKey loadedCircle =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <CircleNoPrimaryKey>(circle.ID);

            //---------------Test Result -----------------------
            Assert.IsNotNull(circleLoadedAsShape);
            Assert.AreEqual(circle.ShapeName, circleLoadedAsShape.ShapeName);

            Assert.IsNotNull(loadedCircle);
            Assert.AreNotSame(loadedCircle, circle);
            Assert.AreSame(loadedCircle, circleLoadedAsShape);
            Assert.AreEqual(circle.Radius, loadedCircle.Radius);
            Assert.AreEqual(circle.ShapeName, loadedCircle.ShapeName);
        }