Previously in this series:
WhoDaBest - Post 1, WhoDaBest - Post 2, WhoDaBest - Post 3
OK, so I've already realized there is a problem with my base repository class. I was getting ready to create my first domain entity, which will be a "Role" class, and it's associated concrete repository and I realized that with the way it is set up, if I just extend the base repository, there is no way of doing any kind of unit tests without putting together some kind of test database and this just won't do. I don't want the overhead, especially since I don't want to test the ActiveRecord functions.
So now I have to back up a step. I really do need some way to inject the ActiveRecordMediator into my repository. Then I can mock the mediator for unit tests. So I've created a RepositoryMediator class which basically wraps all of the ActiveRecordMediator static calls as instance methods. This class implements the IRepositoryMediator interface which describes all of these calls. My base repository now accepts an IRepositoryMediator via constructor injection. Now I can mock this IRepositoryMediator (for which I will be using Rhino Mocks) and pass it into my concrete repositories.
Although it seems like this is jumping through some hoops, it also abstracts out the ActiveRecordMediator from my BaseRepository class as well. Now it just accepts an IRepositoryMediator instead, which could be implemented using another technology, however unlikely.