简体   繁体   中英

Changing the AppDomain.CurrentDomain Base Directory to another project directory

I am writing unit tests for a solution to having multiple projects inside. While testing, I need to change the Current Domain base directory to that particular project base directory. For eg: since I am writing the unit test the AppDomain.CurrentDomain.BaseDirectory will point to my unit test project directory, but I need to point to another project directory to access some files.

well I suppose that you have certain configuration|data files that are required for running testing code.

You can create additional "test files" and put it to the separate folder just not to mix with the development.

You have to duplicate file modifications on test data files if breaking changes are made in the dev configuration|data files. It is better to share the single set of config|data files between all tests in the solution. You can do it by linking (instead of adding) configuration|data files in the VS Solution explorer and set it's properties copy to output: if newer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM