2
I am using a DLL that has several classes. I would like to dynamically implement interfaces for these classes, so that I can perform unit tests by making a mock of the same.
Is there any way to do that?
Example:
The DLL has a class Comunicador
public class Comunicador
{
public void Executar()
{
//executa
}
}
Is there any way I can get this class to implement the interface below dynamically?
public interface IComunicador
{
void Executar();
}
That way, I want a property
public IComunicador Comunicador { get; set; }
Can you understand the following:
Comunicador = new Comunicador();
It would not be the case to use MEF
– Grupo CDS Informática
It is legacy yes, but as I am implementing new code by TDD I ended up quoting erroneously. The problem of calling this class that is public is that it has called a database, which I cannot do in my unit test. I’ll check the Adapter to see if he’ll pick up, thank you! (And yes, I wouldn’t go so far as to use Reflection just to create such a test)
– Victor Melias
@Grupocdsinformática I don’t think so. MEF is for something else.
– Maniero