-
Notifications
You must be signed in to change notification settings - Fork 73
Description
There's a hardcoded data path used in the MongoDbRunner.StartUnitTest(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin) method:
return new MongoDbRunner(portPool, fileSystem, processStarter, mongoBin, "C:\\data\\db");
This is an oversight, I'm sure - you can pass that parameter in Start and StartForDebugging methods but it's unavailable in StartUnitTest. This is a bad thing, since some people, including me, need to specify the used data directory.
For those that have met the same problem, as a quick and dirty workaround you can simply use reflection to call the constructor yourself (it's generally a big no-no to be touching private constructors, but this'll get you moving):
_dataDir = @"c:\my\own\path\to\data";
var constructor = typeof(MongoDbRunner).GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance,
null,
new Type[]
{
typeof(IPortPool),
typeof(IFileSystem),
typeof(IMongoDbProcessStarter),
typeof(IMongoBinaryLocator),
typeof(string)
}, null);
_runner = (MongoDbRunner)constructor.Invoke(new object[]
{
PortPool.GetInstance, new FileSystem(), new MongoDbProcessStarter(), new MongoBinaryLocator(null), _dataDir
});
Summarized: StartUnitTest could use another parameter to let us define what data directory to use.