lundi 3 août 2015

Mock a concrete class

I know that it is not possible to Mock a concrete class but only interfacecs and abstract classes. Is there any way or any pattern to skirt this?

For example I have the following classes that do not implement any interface. I don't want to create a new instance of C since it will take lot of time in my unit test, how can I mock it and do unit test on Foo()?

public class A
{
    public virtual void Foo(){}
}

public class C:A
{
    public C()
    {
        // construction takes lot of time    
    }

    public override void Foo()
    {
    }
}

Thanks

Aucun commentaire:

Enregistrer un commentaire