/// <summary>
        /// Sets up an object containing conductor dependencies for a given Entity T returned as a composed model.
        /// </summary>
        /// <param name="repository"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        protected IntegrationTestConductors <T> GetRepositoryConductorDeps <T>(IRepository <T> repository) where T : Entity
        {
            var create    = new RepositoryCreateConductor <T>(repository);
            var delete    = new RepositoryDeleteConductor <T>(repository);
            var read      = new RepositoryReadConductor <T>  (repository);
            var update    = new RepositoryUpdateConductor <T>(repository);
            var conductor = new RepositoryConductor <T>(create, read, update, delete);

            return(new IntegrationTestConductors <T>
            {
                Conductor = conductor,
                Create = create,
                Delete = delete,
                Read = read,
                Repository = repository,
                Update = update
            });
        }
        public static T Create <T>(this T entity, IContext context) where T : Entity
        {
            var cachedCreatedOn = (entity is Auditable) ? (entity as Auditable).CreatedOn : null;
            var repository      = new RepositoryCreateConductor <T>(new Repository <T>(context));
            var createResult    = repository.Create(entity);

            createResult.ThrowIfAnyErrors();

            if (cachedCreatedOn == null)
            {
                return(createResult.ResultObject);
            }

            // Allow createdOn to be explicitly set from testing
            Console.WriteLine("EntityExtensions.Create explicit CreatedOn supplied performing additional update.");
            (createResult.ResultObject as Auditable).CreatedOn = cachedCreatedOn;
            var updateRepository = new RepositoryUpdateConductor <T>(new Repository <T>(context));
            var updateResult     = updateRepository.Update(createResult.ResultObject);

            updateResult.ThrowIfAnyErrors();

            return(createResult.ResultObject);
        }