This example highlights how to simulate working with the UnixFileMode in the MockFileSystem.
The DefaultUnixFileModeStrategy simulates the user and group and stores this information alongside the file/directory in the OnSetUnixFileMode method.
Later in the IsAccessGranted method you can access the stored data from the IFileSystemExtensibility and act accordingly to read or write requests in the MockFileSystem.
Read access is granted when
- When the unix file mode is set to
OtherReadOR - When the unix file mode is set to
GroupReadand the simulated group of the file is the same as the currently simulated group - When the unix file mode is set to
UserReadand the simulated user of the file is the same as the currently simulated user
The same logic applies to write access.
Simulating a user or group is done by calling SimulateUser/SimulateGroup on the DefaultUnixFileModeStrategy.