Created
September 18, 2012 21:33
-
-
Save jrusbatch/3746069 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 DocumentSessionFactory : IDisposable | |
{ | |
private readonly IDocumentStore documentStore; | |
public DocumentSessionFactory() | |
{ | |
documentStore = new EmbeddableDocumentStore { RunInMemory = true }; | |
documentStore.Initialize(); | |
} | |
public IAsyncDocumentSession CreateSession() | |
{ | |
var db = string.Format("db-{0:N}", Guid.NewGuid()); | |
// Throws `NullReferenceException` w/ v1.2.2085-unstable from nuget. | |
return documentStore.OpenAsyncSession(db); | |
} | |
public void Dispose() | |
{ | |
if (documentStore != null) | |
{ | |
documentStore.Dispose(); | |
} | |
} | |
} |
khalidabuhakmeh
commented
Sep 18, 2012
This will return a new document store. You can either use it per Fixture or per Unit test. I also like to call IndexCreation and seed all my indexes as well.
Oh, wow. I didn't notice that property. Thanks!
FWIW RunInUnreliableYetFastModeThatIsNotSuitableForProduction https://groups.google.com/forum/?fromgroups=#!topic/ravendb/vkiqoiZ6Fsc doesn't seem like it matters at all. RunIN... is for Esent and RunInMemory = Munin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment