Domanda

My English not good. But I think code you can understand. I have two class, like this: classB:classA classA is classB parent. Now I hava two interface like this: IclassB,IclassA. classA have a method. like this: classA.GetAllData(); I want write unit test. I want to test classB.GetData(); classB.GetData() method like this:classB.GetData(){ return classA.GetAllData(); }

So, I mock classA.GetAllData(). like this:var mockAStub= MockRepository.GenerateStub<IclassA>(); var mockA = new classA(mockAStub); mockA.stub(s=>s.....

test method can not go to the mockA method, Do you know how to do this ?

È stato utile?

Soluzione

I think what you want to do is :

var mockAStub = MockRepository.GenerateStub(); mockAStub.Stub(s => s.GetAllData()).....

classB.GetData();

And maybe asserting the method mockAStub.GetAllData() is called like this :

mockAStub.AssertWasCalled(s => s.GetAllData());

Hope this help

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top