Turns out I am storing the document correctly so the beginning part of this question is not correct, probably due to my inexperience with RavenDB. However I still have the question of being able to open the RavenDB Management Studio while using an EmbeddableDocumentStore in a unit test.
I seem to be running into a problem storing documents in the EmbeddableDocumentStore during a unit test using NUnit. In order to see if I am actually storing the document I am trying to connect to the embedded database.
When trying to open the url http://computername:8080/ (for some reason raven db always uses the computer name on my pc) the browser loading bar just spins and if I stop the unit test and try the url again Chrome just gives me the message that it could not connect. Here's some code for context.
[TestFixture]
public class Test2 : IDisposable
{
private EmbeddableDocumentStore _documentStore;
[SetUp]
public void SetUp()
{
if (_documentStore != null) return;
_documentStore = new EmbeddableDocumentStore
{
DataDirectory = "Data",
RunInMemory = true,
UseEmbeddedHttpServer = true
};
_documentStore.Configuration.AnonymousUserAccessMode = AnonymousUserAccessMode.All;
_documentStore.Initialize();
}
[Test]
public void Test()
{
var document = StaticData.getdocument();
using (var session = _documentStore.OpenSession())
{
session.Store(document);
session.SaveChanges();
}
using (var session = _documentStore.OpenSession())
{
var test = session.Load<ObjectType>().Length;
//This is always 0
}
}
public void Dispose()
{
_documentStore.Dispose();
}
}
Also I have the Raven.Studio.xap file in the root of my Test project.
I am using VS2012, and .Net 4.5 if that makes a difference.
Here you go:
static public void WaitForUserToContinueTheTest(EmbeddableDocumentStore documentStore, bool debug = true)
{
if (debug && Debugger.IsAttached == false)
return;
documentStore.SetStudioConfigToAllowSingleDb();
documentStore.DatabaseCommands.Put("Pls Delete Me", null,
RavenJObject.FromObject(new { StackTrace = new StackTrace(true) }),
new RavenJObject());
documentStore.Configuration.AnonymousUserAccessMode = AnonymousUserAccessMode.All;
using (var server = new HttpServer(documentStore.Configuration, documentStore.DocumentDatabase))
{
server.StartListening();
Process.Start(documentStore.Configuration.ServerUrl); // start the server
do
{
Thread.Sleep(100);
} while (documentStore.DatabaseCommands.Get("Pls Delete Me") != null && (debug == false || Debugger.IsAttached));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With