mercredi 25 mars 2015

Mocking Instance Variable in Subclass

I have a class



public class C1 : A1<I1, I2<I1>, I3<Doc>, I4<I1>, C2>


A1 is defined as



public abstract class A1<TA, TB, TC, TD, TE> : A1<TA, TE>


The class it inherits from is defined thus



public abstract class A1<TA, TE> : A2<TA, TE>


A2 is defined like this



public abstract class A2<TA, TE> : A3<TA>
{
protected readonly Foo<TA, TE> Foo;

protected A2(Foo<TA, TE> foo)
{
Foo = foo;
}


I am testing C1 using Rhino Mocks and I want to mock a method Bar on Foo. I am having trouble doing this.


I have tried, this but it does not work.



var mock = MockRepository.GenerateMock<A2<I1, C2>>();
mock.Stub(m => m.Bar())
.Return("output");


What am I doing wrong?


Aucun commentaire:

Enregistrer un commentaire