views:

119

answers:

1

I had a winforms C# class that internally was looking up a file.. to help unit test, i changed it to pass in a file from the outside such as:

string file = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location + "TestXML.xml");

Foo = new Foo(file);

the problem is that the code works fine normally but when run in Nunit it comes us with an error saying "Cant find directory C:\doc & settings\ . . .. testxml.xml

any thoughts?

+2  A: 

I would set a breakpoint and then use the immediate window to find out what is getting passed to GetDirectoryName. It probably isn't what you intended.

BioBuckyBall