You can use #DEBUG (see Johns answer) for classes.
For resources you can edit the MSBuild script file to include parts of the project conditionally based on the build mode selected.
The .csproj file is a XML MSBuild script, if you open it up in a text editor, you should find inside all of the parts of your project. If you can locate the parts you want to exclude from certain builds you can mark them with the Condition property. For example, to make a ItemGroup only be built for the Debug configuration you would do this:
<ItemGroup Condition=" '$(Configuration)' == 'Debug' " ...
You should be able to take a look though this and find the resources you want to exclude and add a similar Condition property to them, or to their parent group.
Like Jon says though, I would recommend that you use a separate assembly for test stuff and don't let it get mixed up with you main assemblies. (Also see John's answer for how to do Debug only classes)