/// <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);
            }		
        }
			private static bool IsInversionOfControlContainerOutOfSynchWith(UnitOfWorkTestContext context)
			{
				return (IoC.IsInitialized == false) != (context.RhinoContainer == null);
			}
	    /// <summary>
		/// Throw away all <see cref="UnitOfWorkTestContext"/> objects within <see cref="Contexts"/>
		/// and referenced by <see cref="CurrentContext"/>. WARNING: Subsequent calls to  <see
		/// cref="InitializeNHibernateAndIoC(PersistenceFramework,string,DatabaseEngine,string,MappingInfo)"/>
		/// and all its overloads will now take considerably longer as the persistent framework will
		/// be initialised a fresh.
		/// </summary>
		/// <remarks>
		/// This method should be used vary sparingly. It is highly unlikely that you will need to
		/// call this method between every test.
		/// <para>
		/// Calling this method will dispose of <see cref="UnitOfWorkTestContext"/> objects within
		/// <see cref="Contexts"/>. Each context maintains a reference to a 
		///  <see cref="RhinoContainer"/>. If this container object is
		/// referenced by <see cref="IoC"/>.<see cref="IoC.Container"/> then any subsequent calls to <see
		/// cref="IoC"/>.<see cref="IoC.Resolve(Type)"/> and any of the overloads will throw.
		/// </para>
		/// </remarks>
		public static void DisposeAndRemoveAllUoWTestContexts()
		{
			foreach (UnitOfWorkTestContext context in Contexts)
				context.Dispose();

			CurrentContext = null;
			IsRunningInTestMode = false;
			Contexts.Clear();
        }