* limitations under the License.
*/
-using LibTVRefCommonPortable.Stubs;
using System;
+using System.Collections.Generic;
using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
using Xamarin.Forms;
namespace LibTVRefCommonPortable.Utils
private static IFileSystemAPIs fileSystemAPIs;
/// <summary>
- /// A instance of file system watcher port layer
- /// </summary>
- private static IFileSystemWatcherAPIs fileSystemWatcherAPIs;
-
- /// <summary>
/// A instance of FileSystemUtils
/// </summary>
private static readonly FileSystemUtils instance = new FileSystemUtils();
}
/// <summary>
- /// A property of file system watcher instance
+ /// A unit test stub for FileSystemUtils
/// </summary>
- public IFileSystemWatcherAPIs FileSysteamWatcherInstance
+ private class TestStub : IFileSystemAPIs
{
- get
+ /// <summary>
+ /// A directory path which should be used for app data storing.
+ /// </summary>
+ public string AppDataStorage
+ {
+ get
+ {
+ return "test_app_data_path/";
+ }
+ }
+
+ /// <summary>
+ /// A directory path which should be used for app resource storing.
+ /// </summary>
+ public string AppResourceStorage
+ {
+ get
+ {
+ return "test_app_resource_path/";
+ }
+ }
+
+ /// <summary>
+ /// A directory path which should be used for sharing between apps.
+ /// </summary>
+ public string PlatformShareStorage
+ {
+ get
+ {
+ return "test_platform_share_path/";
+ }
+ }
+
+ /// <summary>
+ /// A method closes the file.
+ /// </summary>
+ /// <param name="stream">A file descriptor</param>
+ public void CloseFile(Stream stream)
+ {
+ }
+
+ /// <summary>
+ /// A method flushing the stream to write remains.
+ /// </summary>
+ /// <param name="stream">A file descriptor</param>
+ public void Flush(Stream stream)
{
- return fileSystemWatcherAPIs;
+ }
+
+ /// <summary>
+ /// A method checks if a file existence in the file system.
+ /// </summary>
+ /// <param name="filePath">A file path</param>
+ /// <returns>An existence of the file</returns>
+ public bool IsFileExist(string filePath)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// A method checks if file is read to use.
+ /// </summary>
+ /// <param name="filePath">A file path</param>
+ /// <returns>A status of ready</returns>
+ public bool IsFileReady(string filePath)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// A method opens a file on the given mode.
+ /// </summary>
+ /// <param name="filePath">A file path</param>
+ /// <param name="mode">An opening mode</param>
+ /// <returns>A file descriptor</returns>
+ public Stream OpenFile(string filePath, UtilFileMode mode)
+ {
+ throw new NotImplementedException();
}
}
/// </summary>
private FileSystemUtils()
{
- fileSystemAPIs = new FileSystemAPITestStub();
- fileSystemWatcherAPIs = new FileWatcherAPITestStub();
+ fileSystemAPIs = new TestStub();
try
{
{
fileSystemAPIs = DependencyService.Get<IFileSystemAPIs>();
}
-
- if (DependencyService.Get<IFileSystemWatcherAPIs>() != null)
- {
- fileSystemWatcherAPIs = DependencyService.Get<IFileSystemWatcherAPIs>();
- }
}
catch (InvalidOperationException e)
{