Get path of referenced project during unit testing
I suggest you do something like this:
public class MyXslFileLoader
{
public void Load()
{
Load(AppDomain.CurrentDomain.BaseDirectory + "\XML Transformationen\Transformation_01.xslt");
}
public void Load(string path)
{
Xsl = GetXSLFromFile(path);
}
}
You would call Load()
in your web application, but use the overloaded version of this method in your unittest application. You could consider adding the xslt file as a resource to your project.
You would be able to load the path like this:
var webApplicationDllPath = Path.GetDirectoryName(typeof(ClassInTheWebApplicationDll).Assembly.GetName().CodeBase);
string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
HOW TO: Determine the Executing Application's Path
Getting the path of a executable file in C#
Hope this is helpful.. :)