Project A - Web Application/Website
Project B - Unit Test Application
I'm familiar how to do Unit Tests in multiple projects if it's something such as incrementCounter(ByRef nCounter As Integer)
or getSquare(ByVal nValue As Integer)
. However, I'm being asked to create a Unit Test in Project B that calls a function in Project A and verifies a new record in a table. My issue is when I do so, it builds fine but has a runtime exception when trying to connect to the database (using a config file). My question is, do I need to have the same config file in Project B that is in Project A, or can Unit Testing a function in a website in this manner not be accomplished?
I would prefer to put the Unit Test in Project A but I don't have approval to do that at this moment (boss is on vacation and unreachable). I've also though of conditional statements to see if the function is being called by Unit Testing or through the browser, but that might be more work than is required. Any and all help is appreciated. Thanks.
UPDATE The actual error I'm getting is...
Class.Function-->The key 'OraConnection.ConnectionString' does not exist in the appSettings Configuration section.
I'm going to see if it's just a setting or if it's in the app.config file because I've copied it over to the other project, but am still getting the error. Thanks.
UPDATE 2
After looking around some more, Project A is a class library. However, I talked to a coworker and they informed me that the web.config files loads whatever settings are in the app.config file on launch. Also, none of the app.config files I have seem to have the database connection so it seems like a sourcing issue (or their clever way to keep things hidden). I'm trying to find a properly configured app.config file and then will test. Thanks everyone.