Remco;4970 wrote:I've built a small test environment making use of a file in the same way as above, but strangely, it seems to work without problems for me when attempting to find the file in the same directory as the test assembly. Would you be able to show me how you are looking for this file? I'm wondering if there may be another dimension to this.
Can you also confirm which version of Visual Studio you're running?
Also note that you can inspect the workspace being used by NCrunch by right clicking on the project or test, then going to Advanced->Browse to workspace. This can be useful when trying to determine if the issue is in the way the workspace is constructed, or if its related to the way the workspace is being used.
The call to load the file is
if (File.Exists(path))
{
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (StreamReader rdr = new StreamReader(fs))
{
json = rdr.ReadToEnd();
}
}
}
VS 2012 with all the updates
I can confirm the file is not in the workspace, but it is in the debug bin directory of the project.
When I check what directory ncrunch is looking it comes back with \AppData\Local\NCrunch\5820\19\SECFillingsTool\bin\ (current assembly location) but when running from visual studio it's coming back with \TestResults\Deploy_yuriy.faktorovich 2013-12-22 10_41_03\Out\.
My guess is the step you're missing is that it is in a subdirectory of the project being tested, but inside the project directory of the test project.