Reputation: 153
After following RavenDB's documentation
http://ravendb.net/docs/article-page/2.5/csharp/samples/raven-tests/createraventests
I am not able to successfully get a unit test to run past the creation of the in memory document store. I copy and pasted the test sample found in the documentation above using RavenDB's 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
};
}
}
Upon reaching NewDocumentStore()... I receive the following exception:
"Exception was unhandled by user code Voron is prone to failure in 32-bits mode. Use Raven/Voron/AllowOn32Bits to force voron in 32-bit process."
I am using Visual Studio 2013 (Update 4) and RavenDB 3.0
Thanks!
Upvotes: 15
Views: 1934
Reputation: 10561
RavenTestBase
provides a number of virtual members that you can override to do common configuration for things like this.
I create an intermediate type that inherits from RavenTestBase
that does my common configuration and then use that intermediate type as the parent type for my tests...
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
{
...
}
Upvotes: 3
Reputation: 1016
In the constructor for NewDocumentStore pass in the configureStore parameter. This is an Action that takes the EmbeddableDocumentStore as its parameter. Within that action you can set different parts of the Configuration, including the AllowOn32Bits property.
public void ConfigureTestStore(EmbeddableDocumentStore documentStore)
{
documentStore.Configuration.Storage.Voron.AllowOn32Bits = true;
}
Then pass this as the configureStore argument in the constructor.
using (var store = NewDocumentStore(configureStore:ConfigureTestStore))
Upvotes: 12