Hi Owen,
Thanks, that makes alot of sense, I especially like the
TheEmployeeShouldReturnTheSameGroupIfRequestedAgain method.
By using the object with a factory passed in you would test that the
Create gets called. Then there are other tests for factory.Create to
check that it works properly, that's the separation of
responsibilities.
I got a couple of questions though for clarification:
- So by this design , does this mean that I should have at the maximum
have a factory for every related collection or object, or at the least
have one factory, e.g a IEmployeeRelatedObjectsFactory which would
have every Create for every collection or related object ?
- Secondly, as a result of a factory being passed in this means that
the UI would have a factory/factories for every business object that
is being used. This seems a bit much because the UI shouldn't care
about how or what the business objects uses to get its relations or
carry out its functions. How would the UI change as a result ? Is
there another layer ?
- Just as a side question, Im guessing the easiest refactoring method
would be to pass the factory into the collection constructor or
related object ?
Thanks again,
Tariq
On Feb 26, 9:30 am, "Owen Evans" <
owenmcev...@gmail.com> wrote:
> So just going on your example, take a look at what the system under test
> should do... one of two things,
> a) get a new EmployeeGroupsCollection if none exists
> b) return the original EmployeeGroupsCollection if it existed already
>
> so these can be boiled down to doing the following:
> [TestFixture]
> public void GivenANewEmployeeGroupsCollection()
> {> private IEmployee employee;