I am writing Unit tests for a Windows Project. The Executable project on the Client Side of this Windows Project has a code File.Exists("LanguageLookups.sdf") which is used to check and return a Bool if the sdf file exists in the Execution Directory or not. But when i execute the same piece of Code through a Unit test; The code File.Exists("LanguageLookups.sdf") returns a FALSE. Its not able to find this SDF File. Can anybody help me on this?
views:
58answers:
3
A:
You might want to check the current working directory of the unit test using Environment.CurrentDirectory. Your unit test runner most likely is not running your test with the same working directory as your Windows application, and therefore your unit test cannot find the file because it is looking in the wrong directory.
adrianbanks
2009-12-04 16:32:30
Hi Adrian,Thanks a lot!!!!! I could solve this problem. I set the Current Directory to my Windows Application. This solved the problem. Thanks a lot again!!!1
2009-12-06 10:20:15
A:
I'd guess that it's not running from the execution directory.
Use an absolute path and see if it works.
Bravax
2009-12-04 16:32:31
A:
File.Exists docs talks about the GetCurrentDirectory() and building up an absolute path.
neouser99
2009-12-04 16:33:55