Revert "Add Test cases for app shortcut, managedapps"
[profile/tv/apps/dotnet/home.git] / LibTVRefCommonPortable / Utils / FileSystemUtils.cs
index 4ed3434..3497da7 100644 (file)
  * 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
@@ -32,11 +35,6 @@ 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();
@@ -53,13 +51,88 @@ namespace LibTVRefCommonPortable.Utils
         }
 
         /// <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();
             }
         }
 
@@ -68,8 +141,7 @@ namespace LibTVRefCommonPortable.Utils
         /// </summary>
         private FileSystemUtils()
         {
-            fileSystemAPIs = new FileSystemAPITestStub();
-            fileSystemWatcherAPIs = new FileWatcherAPITestStub();
+            fileSystemAPIs = new TestStub();
 
             try
             {
@@ -77,11 +149,6 @@ namespace LibTVRefCommonPortable.Utils
                 {
                     fileSystemAPIs = DependencyService.Get<IFileSystemAPIs>();
                 }
-
-                if (DependencyService.Get<IFileSystemWatcherAPIs>() != null)
-                {
-                    fileSystemWatcherAPIs = DependencyService.Get<IFileSystemWatcherAPIs>();
-                }
             }
             catch (InvalidOperationException e)
             {