Created
August 24, 2011 20:01
-
-
Save damianh/1169038 to your computer and use it in GitHub Desktop.
RavenDB DocumentSession transaction tests
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 RavenDbTransactionTest | |
{ | |
[Fact] | |
public void RemoteDocumentStore_ShouldNotThrow() | |
{ | |
var documentStore = new DocumentStore() | |
{ | |
Url = "http://localhost:8080" | |
}; | |
documentStore.Initialize(); | |
DoStore(documentStore); | |
DoStore(documentStore); | |
documentStore.Dispose(); | |
} | |
[Fact] | |
public void EmbeddedDocumentStore_ShouldNotThrow() | |
{ | |
var documentStore = new EmbeddableDocumentStore() | |
{ | |
DataDirectory = "Data" | |
}; | |
documentStore.Initialize(); | |
DoStore(documentStore); | |
DoStore(documentStore); | |
documentStore.Dispose(); | |
} | |
[Fact] | |
public void InMemoryDocumentStore_ShouldNotThrow() | |
{ | |
var documentStore = new EmbeddableDocumentStore() | |
{ | |
RunInMemory = true | |
}; | |
documentStore.Initialize(); | |
DoStore(documentStore); | |
DoStore(documentStore); | |
documentStore.Dispose(); | |
} | |
private static void DoStore(IDocumentStore documentStore) | |
{ | |
using (new TransactionScope()) | |
using (var session = documentStore.OpenSession()) | |
{ | |
var entity = new Entity { Id = "Test" }; | |
session.Store(entity); | |
session.SaveChanges(); | |
} | |
} | |
public class Entity | |
{ | |
public string Id { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment