PeersManagerImplTest feedback

Hi Petr,

just looked at you latest revision. I got a little confused by PeersManager at first - I though you were working on the SessionsManager. If the DHT nodes are also called Trackers, then I’d support your suggestion to rename the class back to TrackerManager.

I think you shouldn’t need the trick with PeersRequestMockedSessionPtr. Try with:

auto_ptr < (PeersRequestSessionMock> requestSession;

which you initialize accordingly in setUp() and clean up in tearDown().

Then the test would simply look like that:

call (peersManager->start (torrent))
.willCall (peersRequestSessionFactory->createSession())
.willReturn (*requestSession)
.returns();

The trick here is that requestSession is an auto_ptr to a Mock class but the Mock classes provide cast operators to the interface they are mocking. Dereferencing the auto_ptr returns a reference to the interface, so the compiler could do the casting! Let me know if that does not work!

Regards,

Peter

Would you like to post a relpy?


This post starts a thread.
Follow-ups:
Re: PeersManagerImplTest feedback
Hi Petr, I just realized what is the difference in you case... You have created this PeersRequestSessionPtr because the factory is not only passing a pointer but it should be passing the (more...)