I'm using NHibernate for data access and for each table I have a
repository and an interface:
// Here is the repository interface
Public Interface IFooRepository
Foo GetFooById(int ID)
Foo GetFooByName(string name)
// Here is the NHibernate implementation of the repository Interface
Public Class NHibernateFooRepository : IFooRepository
...
So far so good. I'm using Test Driven Development and what I'd like to
do in my unit tests is mock out my IFooRepository so that I can mock
out my data access layer when testing business logic (I have seperate
classes for business logic and data access). I could of course create
a MockRepository class and add it to my unit test project:
Public Class MockFooRepository : IFooRepository
public Foo GetFooByID(int ID).....
This works just fine as the GetoFoo.. methods on my MockFooRepository
return exactly what I tell them to. However I have lots of tests and I
want to return different stuff on each test which means I end up with
MockFoo1, MockFoo2, MockFoo3... to cover all the unit test scenarios.
Ideally I'd like to just generate a mock object using Rhino Mocks
based on my interface: IFooRepository. My question is how can I create
a mock object instance based my interface _and_ control what get's
returned from my GetFooById() and GetFooByName() methods. I probably
want these to return something different in each test case. Can I
somehow use a lambda expression or delegate on my unit test class so
that I can wire up custom code for each test case?
Apologies if this obvious or I'm taking totally the wrong approach but
I'm new to Rhino Mocks and the world of Mocking!
--
You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
To post to this group, send email to
rhino...@googlegroups.com.
To unsubscribe from this group, send email to
rhinomocks+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.