Cha*_*kin 6 .net document-database ravendb
原来我正在正确存储文档所以这个问题的开头部分不正确,可能是由于我对RavenDB的经验不足.但是我仍然有一个问题,即在单元测试中使用EmbeddableDocumentStore时能够打开RavenDB Management Studio.
在使用NUnit进行单元测试期间,我似乎遇到了在EmbeddableDocumentStore中存储文档的问题.为了查看我是否实际存储文档,我正在尝试连接到嵌入式数据库.
当试图打开网址http:// computername:8080 /(由于某种原因,乌鸦数据库总是在我的电脑上使用计算机名称)浏览器加载栏只是旋转,如果我停止单元测试并再次尝试网址Chrome只是给出我无法连接的消息.这是上下文的一些代码.
[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();
}
}
Run Code Online (Sandbox Code Playgroud)
我还在我的Test项目的根目录中有Raven.Studio.xap文件.
我正在使用VS2012和.Net 4.5,如果这有所不同.
干得好:
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));
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1564 次 |
| 最近记录: |