-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add events on major events #168
Comments
@zvirja which kind of API do you have in your mind? and can you give example(s). |
For instance, that could be a public property exposed directly from the var fs = new MockFileSystem();
fs.Events.OnFileCreated += (sender, args) => {}
... Basically, nothing special - any way it's convenient to implement. The only requirement is to be able to hook such events :) Let me know if you want more input from me. |
I wouldnt recommend events on the MockFileSystem at the moment. You're basically then implementing a FileSystemWatcher instead. We should make sure the goal is parity with mscorlib. |
I prefer to have a FileSystemWatcher. |
I'm not sure that watcher could cover my initial need why I fired this issue. Initially I wanted to have a way to throw exception when file is opened. That will not be achieved by watcher as it doesn't provide us with appropriate event. Also FileSystemWatcher isn't synchronous by itself (if I'm not mistaken) which also makes it more difficult to simulate concurrency issues. One more point is that watcher provides us with events after action is finished. That way we cannot simulate that action fails (e.g. deletion fails because file is used by other process). Therefore, I'd prefer to have a special API inside the MockFileSystem to be able to intercept all such events. |
I outlined an attempt to do this in #373 and it didn't go over well. It was agreed that this would be too involved for this library. @fgreinacher @ericnewton76 I assume the same answer would apply to this issue? |
In my opinion adding synchronous events like described here would enable quite some scenarios, so I would not reject a PR in this direction. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Sometimes it's needed to test sequence of events with file system and currently it's impossible to do that with current implementation of
MockFileSystem
. Basically, we should add a couple of events, so we could subscribe on that events in our test. Moreover, this way we could simulate various situations (e.g. throw sharing violation exception when particular file is opened).List of events:
I could implement that and create a PR for you. Will you approve such kind of PR?
Do you see some other ways to achieve the desired behavior?
The text was updated successfully, but these errors were encountered: