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
