Skip to content

Instantly share code, notes, and snippets.

@samdelagarza
Created March 25, 2010 13:05
Show Gist options
  • Save samdelagarza/343527 to your computer and use it in GitHub Desktop.
Save samdelagarza/343527 to your computer and use it in GitHub Desktop.
public class InMemoryDatabaseTest : IDisposable
{
private static Configuration _cfg;
private static ISessionFactory _sessionFactory;
protected ISession _session;
public InMemoryDatabaseTest(Assembly assemblyContainingMapping)
{
if (_sessionFactory == null)
{
_sessionFactory =
Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory())
.Mappings(m => m.FluentMappings.AddFromAssembly(assemblyContainingMapping))
.ExposeConfiguration(cfg => _cfg = cfg)
.BuildSessionFactory();
}
_session = _sessionFactory.OpenSession();
new SchemaExport(_cfg).Execute(true, true, false, _session.Connection, Console.Out);
}
public void Dispose()
{
_session.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment