Currently, the FileUtils hold many responsibilities that lead to inconvinience when cover Unit test. This file contains lots of extension functions related to Path class and call App.instance to get list of device paths.
This is not really a good design when refer to a singleton object inside method body, we can not mock the dependency when write test
Solution
Separate FileUtils unto 2 parts. 1 is used to extract the list devices and 1 for extension of Path class
DevicePathsExtractor and its implementation DevicePathsExtractorImpl.
Analysis
Currently, the
FileUtils
hold many responsibilities that lead to inconvinience when cover Unit test. This file contains lots of extension functions related toPath
class and callApp.instance
to get list of device paths. This is not really a good design when refer to a singleton object inside method body, we can not mock the dependency when write testSolution
Separate
FileUtils
unto 2 parts. 1 is used to extract the list devices and 1 for extension ofPath
classDevicePathsExtractor
and its implementationDevicePathsExtractorImpl
.Result
DevicePathsExtractorImpl
PathExt