I am working on library that is supposed to run on both Windows and Linux systems. To work effectively with files I am using MockFileSystem in my tests. I have several test cases where each one of them uses particular configuration file as input. Those config files contain file paths which may be either Windows or Linux style. This brings up a conflict between the file path style and the OS where the tests are running.
As an example please consider following code:
var root = "/home/folder"; //this value is being loaded from config file
var system = new MockFileSystem();
var file = system.Path.Combine(root, "file.txt");
This works fine on Linux and the file variable contains "/home/folder/file.txt". However when the same code runs on Windows the result in file variable is invalid path "/home/folder\file.txt".
At the moment I have to translate all file paths to test machine OS style to be able to test all scenarios. However this is kind of intervention into the logic that is being tested and may lead to different behavior in production code.
As a solution I would appreciate to have an option in MockFileSystem class to specify operating system. MockFileSystem then should behave as if it runs on specified OS independently on real OS of the machine where tests are being run. As of now I just slightly looked into the code and I may not see all consequences and issues that may appear. However, in case that this feature requests will get some support and will be considered as feasible I offer my coding services.
I am working on library that is supposed to run on both Windows and Linux systems. To work effectively with files I am using
MockFileSystemin my tests. I have several test cases where each one of them uses particular configuration file as input. Those config files contain file paths which may be either Windows or Linux style. This brings up a conflict between the file path style and the OS where the tests are running.As an example please consider following code:
This works fine on Linux and the file variable contains
"/home/folder/file.txt". However when the same code runs on Windows the result in file variable is invalid path"/home/folder\file.txt".At the moment I have to translate all file paths to test machine OS style to be able to test all scenarios. However this is kind of intervention into the logic that is being tested and may lead to different behavior in production code.
As a solution I would appreciate to have an option in
MockFileSystemclass to specify operating system.MockFileSystemthen should behave as if it runs on specified OS independently on real OS of the machine where tests are being run. As of now I just slightly looked into the code and I may not see all consequences and issues that may appear. However, in case that this feature requests will get some support and will be considered as feasible I offer my coding services.