Created
March 25, 2010 13:05
-
-
Save samdelagarza/343527 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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