Update: I resolved my problem substituting
var directoryName = Path.GetDirectoryName(typeof (Bootstrapper).Assembly.CodeBase);
With
var directoryName = AppDomain.CurrentDomain.BaseDirectory;
So test work fine now. Anyway i leave question open in case someone could make the original code working (may be explaining why the Bootstraper is better than my solution :) so i can understand why is used here
Original Question
I'm just working with Nancyfx in C#, but i'm just restart to work in last week on c# and probably i'm missing a lot of concept related to dot.net and c#, will study about those in this weekend
Trying to create some test for a nancy module (i use Nunit and helper test class of NancyFx) i have the problem that those tests have to use the Path of the project for which i write the test for(that is for example i write those test in TestProject and i'm testing SelfHostNancyProject). So i need to resolve this problem definitively (actually i manually copied the Views directory of project SelfHostNancyProject in the Views directory of TestProject). But copying around those dir/files even with an automatically post-build command is not the best way.
I discover this solution https://github.com/NancyFx/Nancy/wiki/Nancy-Testing-View-Location but copying the code of class TestingRootPathProvider inside my code i have the error
The type or namespace Bootstrapper cannot be found
public class TestingRootPathProvider : IRootPathProvider
{
private static readonly string RootPath;
static TestingRootPathProvider()
{
var directoryName = Path.GetDirectoryName(typeof Bootstrapper).Assembly.CodeBase);
if (directoryName != null)
{
var assemblyPath = directoryName.Replace(@"file:\", string.Empty);
RootPath = Path.Combine(assemblyPath, "..", "..", "..", "Escape.Web");
}
}
public string GetRootPath()
{
return RootPath;
}
}
But hanging around with google i can't find a solution. I see that seems something related to app inizialization What are Bootstrappers/Bootstrapping in C#
But in any case i don't understand which import i have to do (if any) to resolve the problem or may be there is something i'm missing.