-
-
Notifications
You must be signed in to change notification settings - Fork 10
Labels
Description
The real Directory.EnumerateDirectories will immediately throw IO exceptions for missing directory/etc. (see FileSystemEnumerator.Windows.cs#L48-L50). The equivalent DirectoryMock.EnumerateDirectories will not throw these exceptions until you start to enumerate the result. The same may be true for other methods that return enumerations.
To resolve this, I think InMemoryStorage.EnumerateLocations needs to be split into two methods, something like:
public IEnumerable<IStorageLocation> EnumerateLocations(...)
{
// check for missing directory/etc. and throw exceptions
return EnumerateLocationsImpl(...)
}
private IEnumerable<IStorageLocation> EnumerateLocationsImpl(...)
{
// existing implementation with yield return
}
The checking and throwing in the first method should happen during the initial call, while the code in the second method won't happen until the caller enumerates the result.