Q:

T4 Templates - Generates Unit Test classes from the classes which implement an interface

I have a large number of classes which all use the same interface. This is the first time this code will have unit tests so I'm trying to think of the best way to generate all of these tests, or the structure of the classes at least.
I know T4 Templates are used in EF to generate multiple files based on the model. Is there a way I can specify in the T4 Template that I want it to look at all of the classes which implement an interface and generate a unit test class for each. Alternatively, if it's easier, all of the classes are within the same folder so if I could just point it at that folder it would probably be fine.
Once that is done I can fill in the details of each unit test class with the specfics. I'd obviously have to remove the T4 file so it doesn't overwrite the code I've added to the classes, maybe there is a way to do that too?

A:

Take a look a this blog post:
http://t4-editor.tangible-engineering.com/blog/how-to-generate-multiple-output-files-from-a-single-t4-template.html
It should enable you to generate multiple outputs with a single .tt file. I use it in (almost) the same way you do, I generate a huge class of methods (3000 lines) based on an xml file and then I generate another file containing unit tests for those methods. Ironically, the unit tests pointed out several bugs in my big generated class, even though the unit tests were generated also.

