Skip to content

Instantly share code, notes, and snippets.

@damianh
Created August 24, 2011 20:01
Show Gist options
  • Save damianh/1169038 to your computer and use it in GitHub Desktop.
Save damianh/1169038 to your computer and use it in GitHub Desktop.
RavenDB DocumentSession transaction tests
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