J
joecool1969
Where I work, TPTB have decided that all new projects we work on
(using C#.NET with VS2008 and Team Foundation), shall implement a unit
test project. Something that I have been working on lately writes an
error log (if there were any errors) to a log file in a folder in the
Application Data special folder, like:
c:\documents and settings\myusername\Application Data\mycompanyname
\applicationname
The path to this folder is generated in a public method that is used
to initialize the application and uses the Environment class to get
the special folder path and the Application class to get the company
name and application name.
Now I would like to write a unit test for this method, but the
Application class is different when the application runs under the
context of a unit test. So the test fails.
What is the "best practice" for "test drive development" that will
produce testable code in this case?
(using C#.NET with VS2008 and Team Foundation), shall implement a unit
test project. Something that I have been working on lately writes an
error log (if there were any errors) to a log file in a folder in the
Application Data special folder, like:
c:\documents and settings\myusername\Application Data\mycompanyname
\applicationname
The path to this folder is generated in a public method that is used
to initialize the application and uses the Environment class to get
the special folder path and the Application class to get the company
name and application name.
Now I would like to write a unit test for this method, but the
Application class is different when the application runs under the
context of a unit test. So the test fails.
What is the "best practice" for "test drive development" that will
produce testable code in this case?