private static UnitOfWorkTestContext CreateActiveRecordImplementation(UnitOfWorkTestContextDbStrategy dbStrategy,
                                                                       MappingInfo mappingInfo,
                                                                       string rhinoContainerConfig)
 {
     if (activeRecordType == null)
     {
         activeRecordType = Type.GetType(activeRecordTestContextType);
     }
     if (activeRecordType == null)
     {
         throw new InvalidOperationException("Could not find Active Record context type. Did you forget to reference 'Rhino.Commons.ActiveRecord'?");
     }
     return
         ((UnitOfWorkTestContext)
          Activator.CreateInstance(activeRecordType,
                                   new object[] { dbStrategy, rhinoContainerConfig, mappingInfo }));
 }
        public static UnitOfWorkTestContext For(PersistenceFramework framwork,
                                                string rhinoContainerConfig,
                                                UnitOfWorkTestContextDbStrategy dbStrategy,
                                                MappingInfo mappingInfo)
        {
            switch (framwork)
            {
            case PersistenceFramework.ActiveRecord:
                return(CreateActiveRecordImplementation(dbStrategy, mappingInfo, rhinoContainerConfig));

            case PersistenceFramework.NHibernate:
                return(new NHibernateUnitOfWorkTestContext(dbStrategy, rhinoContainerConfig, mappingInfo));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        /// <summary>
        /// Initialize NHibernate, build a session factory, and initialize the container.
        /// If <paramref name="rhinoContainerConfig"/> is <see langword="null" /> or <see cref="string.Empty">string.Empty</see>
        /// a <see cref="RhinoContainer">RhinoContainer</see> will not be initialized.
        /// </summary>
        /// <param name="rhinoContainerConfig">The configuration file to initialize a <see cref="RhinoContainer">RhinoContainer</see>
        /// or <see langword="null" />.</param>
        /// <param name="assemblies">The assemblies to load for NHibernate mapping files.</param>
        public static void FixtureInitialize(string rhinoContainerConfig, params Assembly[] assemblies)
        {
            if (context == null)
            {
                UnitOfWorkTestContextDbStrategy dbStrategy =
                    UnitOfWorkTestContextDbStrategy.For(DatabaseEngine.MsSqlCe, DatabaseFilename);
                context =
                    UnitOfWorkTestContext.For(PersistenceFramework.NHibernate,
                                              rhinoContainerConfig,
                                              dbStrategy,
                                              MappingInfo.From(assemblies));
            }

            if (!string.IsNullOrEmpty(context.RhinoContainerConfigPath))
            {
                if (!IoC.IsInitialized)
                {
                    IoC.Initialize(context.RhinoContainer);
                }
                NHibernateUnitOfWorkFactory hibernateUnitOfWorkFactory = (NHibernateUnitOfWorkFactory)IoC.Resolve <IUnitOfWorkFactory>();
                hibernateUnitOfWorkFactory.RegisterSessionFactory(context.SessionFactory);
            }
        }
            public static NHibernateInitializer Initialize(PersistenceFramework framework, MappingInfo mappingInfo)
            {
                NHibernateInitializer initializer = new NHibernateInitializer(framework, mappingInfo);

                return(initializer);
            }
 public static void IntializeNHibernate(PersistenceFramework framework, MappingInfo mappingInfo)
 {
     InitializeNHibernate(framework, mappingInfo);
 }
 public static void IntializeNHibernateAndIoC(PersistenceFramework framework, string rhinoContainerConfig, DatabaseEngine databaseEngine, MappingInfo mappingInfo)
 {
     InitializeNHibernateAndIoC(framework, rhinoContainerConfig, databaseEngine, mappingInfo);
 }
 /// <summary>
 /// See <see cref="InitializeNHibernateAndIoC(PersistenceFramework,string,DatabaseEngine,string,MappingInfo)"/>
 /// </summary>
 public static void InitializeNHibernateAndIoC(PersistenceFramework framework, string rhinoContainerConfig, DatabaseEngine databaseEngine, MappingInfo mappingInfo)
 {
     NHibernateInitializer.Initialize(framework, mappingInfo).Using(databaseEngine, null).AndIoC(rhinoContainerConfig);
 }
 /// <summary>
 /// See <see cref="InitializeNHibernateAndIoC(PersistenceFramework,string,DatabaseEngine,string,MappingInfo)"/>
 /// </summary>
 public static void InitializeNHibernateAndIoC(PersistenceFramework framework, string rhinoContainerConfig, MappingInfo mappingInfo)
 {
     NHibernateInitializer.Initialize(framework, mappingInfo).AndIoC(rhinoContainerConfig);
 }
 public NHibernateUnitOfWorkTestContext(UnitOfWorkTestContextDbStrategy dbStrategy,
                                        string rhinoContainerConfigPath,
                                        MappingInfo assemblies)
     : base(dbStrategy, rhinoContainerConfigPath, assemblies)
 {
 }