RavenDB:获取内存文档存储异常 "Voron is prone to failure in 32-bits mode."
RavenDB: Getting exception for in memory Document Store "Voron is prone to failure in 32-bits mode."
遵循 RavenDB 的文档
http://ravendb.net/docs/article-page/2.5/csharp/samples/raven-tests/createraventests
我无法成功地进行单元测试 运行 在创建内存文档存储之后。我使用 RavenDB 的 RavenTestBase 复制并粘贴了在上述文档中找到的测试示例。
[TestClass]
public class IndexTest : RavenTestBase
{
[TestMethod]
public void CanIndexAndQuery()
{
using (var store = NewDocumentStore())
{
new SampleData_Index().Execute(store);
using (var session = store.OpenSession())
{
session.Store(new SampleData
{
Name = "RavenDB"
});
session.SaveChanges();
}
using (var session = store.OpenSession())
{
var result = session.Query<SampleData, SampleData_Index>()
.Customize(customization => customization.WaitForNonStaleResultsAsOfNow())
.FirstOrDefault();
Assert.Equals(result.Name, "RavenDB");
}
}
}
}
public class SampleData
{
public string Name { get; set; }
}
public class SampleData_Index : AbstractIndexCreationTask<SampleData>
{
public SampleData_Index()
{
Map = docs => from doc in docs
select new
{
doc.Name
};
}
}
到达 NewDocumentStore() 时...我收到以下异常:
“用户代码未处理异常
Voron 在 32 位模式下容易出错。在 32 位进程中使用 Raven/Voron/AllowOn32Bits 强制 voron。"
我正在使用 Visual Studio 2013(更新 4)和 RavenDB 3.0
谢谢!
在 NewDocumentStore 的构造函数中传入 configureStore 参数。这是一个将 EmbeddableDocumentStore 作为其参数的 Action。在该操作中,您可以设置配置的不同部分,包括 AllowOn32Bits 属性.
public void ConfigureTestStore(EmbeddableDocumentStore documentStore)
{
documentStore.Configuration.Storage.Voron.AllowOn32Bits = true;
}
然后将其作为构造函数中的 configureStore 参数传递。
using (var store = NewDocumentStore(configureStore:ConfigureTestStore))
RavenTestBase
提供了许多虚拟成员,您可以重写这些虚拟成员来为此类事情进行通用配置。
我创建了一个继承自 RavenTestBase
的中间类型,它执行我的常用配置,然后将该中间类型用作我的测试的父类型...
public abstract class IntermediateRavenTestBase : RavenTestBase
{
protected override void ModifyConfiguration(InMemoryRavenConfiguration configuration)
{
base.ModifyConfiguration(configuration);
// add any plugins you might use...
configuration.Catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodaTimeCompilationExtension).Assembly));
}
protected override void ModifyStore(EmbeddableDocumentStore documentStore)
{
base.ModifyStore(documentStore);
// any common document store config changes...
// including the Voron setting
documentStore.Configuration.Storage.Voron.AllowOn32Bits = true;
documentStore.ConfigureForNodaTime();
documentStore.Conventions.DefaultQueryingConsistency = ConsistencyOptions.AlwaysWaitForNonStaleResultsAsOfLastWrite;
documentStore.Conventions.JsonContractResolver = new CustomContractResolver();
}
}
[TestClass]
public class IndexTest : IntermediateRavenTestBase
{
...
}
遵循 RavenDB 的文档
http://ravendb.net/docs/article-page/2.5/csharp/samples/raven-tests/createraventests
我无法成功地进行单元测试 运行 在创建内存文档存储之后。我使用 RavenDB 的 RavenTestBase 复制并粘贴了在上述文档中找到的测试示例。
[TestClass]
public class IndexTest : RavenTestBase
{
[TestMethod]
public void CanIndexAndQuery()
{
using (var store = NewDocumentStore())
{
new SampleData_Index().Execute(store);
using (var session = store.OpenSession())
{
session.Store(new SampleData
{
Name = "RavenDB"
});
session.SaveChanges();
}
using (var session = store.OpenSession())
{
var result = session.Query<SampleData, SampleData_Index>()
.Customize(customization => customization.WaitForNonStaleResultsAsOfNow())
.FirstOrDefault();
Assert.Equals(result.Name, "RavenDB");
}
}
}
}
public class SampleData
{
public string Name { get; set; }
}
public class SampleData_Index : AbstractIndexCreationTask<SampleData>
{
public SampleData_Index()
{
Map = docs => from doc in docs
select new
{
doc.Name
};
}
}
到达 NewDocumentStore() 时...我收到以下异常:
“用户代码未处理异常 Voron 在 32 位模式下容易出错。在 32 位进程中使用 Raven/Voron/AllowOn32Bits 强制 voron。"
我正在使用 Visual Studio 2013(更新 4)和 RavenDB 3.0
谢谢!
在 NewDocumentStore 的构造函数中传入 configureStore 参数。这是一个将 EmbeddableDocumentStore 作为其参数的 Action。在该操作中,您可以设置配置的不同部分,包括 AllowOn32Bits 属性.
public void ConfigureTestStore(EmbeddableDocumentStore documentStore)
{
documentStore.Configuration.Storage.Voron.AllowOn32Bits = true;
}
然后将其作为构造函数中的 configureStore 参数传递。
using (var store = NewDocumentStore(configureStore:ConfigureTestStore))
RavenTestBase
提供了许多虚拟成员,您可以重写这些虚拟成员来为此类事情进行通用配置。
我创建了一个继承自 RavenTestBase
的中间类型,它执行我的常用配置,然后将该中间类型用作我的测试的父类型...
public abstract class IntermediateRavenTestBase : RavenTestBase
{
protected override void ModifyConfiguration(InMemoryRavenConfiguration configuration)
{
base.ModifyConfiguration(configuration);
// add any plugins you might use...
configuration.Catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodaTimeCompilationExtension).Assembly));
}
protected override void ModifyStore(EmbeddableDocumentStore documentStore)
{
base.ModifyStore(documentStore);
// any common document store config changes...
// including the Voron setting
documentStore.Configuration.Storage.Voron.AllowOn32Bits = true;
documentStore.ConfigureForNodaTime();
documentStore.Conventions.DefaultQueryingConsistency = ConsistencyOptions.AlwaysWaitForNonStaleResultsAsOfLastWrite;
documentStore.Conventions.JsonContractResolver = new CustomContractResolver();
}
}
[TestClass]
public class IndexTest : IntermediateRavenTestBase
{
...
}