I have a scenario that I want to mock and unit test, but I'm not sure
of the best approach.  I have a class with a constructor that takes an
ID, which then does some validation and hydrates itself from a
mockable data access class.  Customer would be an example class name:

public Customer(int customerID) { ...
 ...validation...
customerDataAccess.LoadTheme(this, customerID);
}

so that you could use this class like:

Customer c = new Customer(123);

The problem is with passing "this" to the mocked method.  At that
point, the mock of ICustomerDataAccess does not update the current
instance.  Under the hood, CustomerDataAccess uses a mockable
IDataAccess, so I could use an actual CustomerDataAccess instance and
instead mock IDataAccess.  That's fine, but I was wondering if anybody
has worked with a scenario like this in the past.  I think I could use
WhenCalled and set properties of the instance that is created, but I'm
not sure that is really what I want to do.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to