var mockFactory=MockRepository.GenerateMock<IJobFactory>();
var jobs=new Collection<IJob>();
for(int i=0;i<5;i++){
var job=MockRepository.GenerateStub<IJob>();
job.Stub(x=>x.Id).Return(i);
}
mockFactory.Stub(x=>x.CreateJobs()).Return(jobs);

will that not do it?

2009/6/30 Ryan <[email protected]>

>
> I have a factory that creates job objects in the form of IJob
>
> Public Interface IJobFactory
>    Function CreateJobs(ByVal cacheTypes As CacheTypes) As IEnumerable
> (Of IJob)
> End Interface
>
> The interface IJob defines three things
>
> Public Interface IJob
>    Sub Execute()
>    ReadOnly Property Id() As Integer
>    ReadOnly Property JobType() As JobType
> End Interface
>
> I am trying to test the consumer of the factory, a class called
> JobManager. The job manager calles IJobFactory and asks for the
> collection of IJobs. I can stub that out just fine but I can't vary
> the collection size without a lot of work.
>
> Is there a simple way to stub out the collection so that I get a range
> back?
>
> How can I create a stub of IJobFactory.CreateJobs in such a way that I
> get back a collection of IJob stubs, say 5 or so where the Id of each
> of the IJob stubs is different. The ids could be 1 through 5 and that
> would work great.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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