public bool AddObject <TEntity>(
            TEntity entity
            )
            where TEntity : class
        {
            GetMockObjectSet <TEntity>().AddObject(entity);
            if (ShouldDeferObjectManagement)
            {
                return(true);
            }
            IObjectManager objectManager = entity as IObjectManager;

            if (!ReferenceEquals(objectManager, null))
            {
                objectManager.ObjectFinishedLoading();
            }
            IBusinessLogic businessLogic = entity as IBusinessLogic;

            if (!ReferenceEquals(businessLogic, null))
            {
                businessLogic.OnAddObject(this);
            }

            return(true);
        }
        private void OnMaterialized(object sender, ObjectMaterializedEventArgs e)
        {
            IObjectManager objectManager = e.Entity as IObjectManager;

            if (ReferenceEquals(objectManager, null))
            {
                return;
            }
            objectManager.ObjectFinishedLoading(this);
        }