I'm writing unit tests for a Website project in Visual Studio. The unit test project needs to reference a few classes that are in the Website project's App_Code.
In order to reference the classes, I am linking the relevant *.cs
files.
Add > Existing Item > Add as Link
If it were a Web Application project not a Website project, then I would reference the assembly. The Website project doesn't appear to have an assembly, though, so my workaround is to link the required *.cs
files instead.
Linking the files does work. It's non-ideal, though, because when we change the *.cs
files in the Website project, they become out of date in the unit test's project (this seems to be a bug), and I subsequently need to remove and re-link them.
The answers at Unit Testing ASP.net Web Site Project code stored in App_Code indicates that moving the classes to a class library project.