I\'m trying to mock DbContext and DbSet. This works for my previous unit tests, but problem occurs while my code was calling ToList method on DbSet second time.
Firs
You return the very same enumerator instance upon each call to GetEnumerator. When it enumerates once, it is done, EF doesn't call its Reset method, rather it asks for a new enumerator.
But you return the one that just has yielded all elements and yields no more.
Instead, return a function that returns the enumerator, that will return a new enumerator each time you ask for it.
q.Setup(m => m.GetEnumerator()).Returns( () => queryableData.GetEnumerator() );