protected internal UnitOfWorkTestContext GetUnitOfWorkTestContext()
            {
                Predicate <UnitOfWorkTestContext> criteria = null;

                if (container == null)
                {
                    criteria = delegate(UnitOfWorkTestContext x)
                    {
                        return(x.Framework == root.PersistenceFramework &&
                               x.RhinoContainerConfigPath == StringOrEmpty(rhinoContainerConfigPath) &&
                               x.DatabaseEngine == root.DatabaseEngine &&
                               x.DatabaseName == root.DatabaseName);
                    };
                }
                else
                {
                    criteria = delegate(UnitOfWorkTestContext x)
                    {
                        return(x.Framework == root.PersistenceFramework &&
                               x.RhinoContainer == container &&
                               x.DatabaseEngine == root.DatabaseEngine &&
                               x.DatabaseName == root.DatabaseName);
                    };
                }


                UnitOfWorkTestContext context = Contexts.Find(criteria);

                if (context == null)
                {
                    UnitOfWorkTestContextDbStrategy dbStrategy =
                        UnitOfWorkTestContextDbStrategy.For(root.DatabaseEngine, root.DatabaseName, root.NHibernateConfigurationProperties);
                    if (container != null)
                    {
                        context = UnitOfWorkTestContext.For(root.PersistenceFramework, container, dbStrategy, root.MappingInfo);
                    }
                    else
                    {
                        context = UnitOfWorkTestContext.For(root.PersistenceFramework, rhinoContainerConfigPath, dbStrategy, root.MappingInfo);
                    }
                    Contexts.Add(context);
                    Debug.Print(string.Format("Created another UnitOfWorkContext for: {0}", context));
                }
                return(context);
            }
        /// <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);
            }
        }