public void Test_DereferenceRelatedObjects_ForSingle_NonOwner_WhenHasNoRelatedBO()
        {
            //The Car has a single relationship to engine. The car->engine relationship is marked 
            // as a dereference related relationship.
            BORegistry.DataAccessor = new DataAccessorInMemory();
            //---------------Set up test pack-------------------
            Car car = new Car();
            car.SetPropertyValue("CarRegNo", "NP32459");
            car.Save();
            car.MarkForDelete();
            new Engine();

            //---------------Assert Precondition----------------
            SingleRelationshipDef relationshipDef = (SingleRelationshipDef)car.Relationships["Engine"].RelationshipDef;
            Assert.IsFalse(relationshipDef.OwningBOHasForeignKey);
            Assert.AreEqual(DeleteParentAction.DereferenceRelated, relationshipDef.DeleteParentAction);
            Assert.IsNull(car.GetEngine());
            //---------------Execute Test ----------------------
            car.Save();
            //---------------Test Result -----------------------
            Assert.IsNull(car.GetEngine());
            Assert.IsTrue(car.Status.IsNew && car.Status.IsDeleted);
        }
        public void TestDereferenceRelatedObjects()
        {
            //The Car has a single relationship to engine. The car->engine relationship is marked 
            // as a dereference related relationship.
            BORegistry.DataAccessor = new DataAccessorInMemory();
            //---------------Set up test pack-------------------

            Car car = new Car();
            car.SetPropertyValue("CarRegNo", "NP32459");
            car.Save();

            Engine engine = new Engine();

            engine.SetPropertyValue("EngineNo", "NO111");
            const string carIDProp = "CarID";
            engine.SetPropertyValue(carIDProp, car.GetPropertyValue(carIDProp));
            engine.Save();

            BORegistry.DataAccessor.BusinessObjectLoader.Refresh(engine);
            Assert.AreSame(engine.GetCar(), car);

            //---------------Execute Test ----------------------
            car.MarkForDelete();
            car.Save();

            //---------------Test Result -----------------------
            Assert.IsNull(engine.GetPropertyValue(carIDProp));
            Assert.IsNull(engine.GetCar());
            //---------------Test TearDown -----------------------
        }