0

I have the duty to make a test class for a method able to load plugins. Plugins are defined as classes that implement the interface IPlugin. The method works receiving a path to a folder and looking for all assemblies in that folder in order to enumerate all plugins defined in these assemblies.

For unit testing, I'd like to generate plugins dinamically, so I could control testing cenarios. All I want is:

1) create a plugin.cs inside my test project and define a plugin. 2) On the test, dynamically create an assembly with the plugin.cs code inside it.

How could it be done in c#?

DocMax
  • 12,094
  • 7
  • 44
  • 44
TapiocaCom
  • 353
  • 5
  • 16
  • Is there a reason you don't want to just add a second project to your solution, creating a second assembly automatically? – Jean-Bernard Pellerin Jan 09 '14 at 19:08
  • While it is somewhat strange that you want to create assemblies at run-time for tests... it is definitely possible and done/asked multiple times. Search and ask update your question with details - i.e. http://stackoverflow.com/questions/21013572/compile-assembly-in-runtime-and-save-dll-in-a-folder – Alexei Levenkov Jan 09 '14 at 19:10

0 Answers0