예제 #1
0
        public void get_file_path_create_test()
        {
            var file = DeviceNoteService.get_file_path("./", true);

            if (File.Exists(file))
            {
                File.Delete(file);
                return;
            }
            Assert.Fail();
        }
예제 #2
0
        public List <DeviceUserEntry> read_entries(string path)
        {
            string filePath = DeviceNoteService.get_file_path(path, false);

            if (filePath == null)
            {
                return(null);
            }

            String data;

            try
            {
                data = File.ReadAllText(filePath);
            }
            catch (Exception e)
            {
                if (e.GetType().IsAssignableFrom(typeof(System.IO.FileNotFoundException)))
                {
                    Console.WriteLine("No Entries found.");
                }
                else
                {
                    Console.WriteLine(e.ToString());
                }
                return(null);
            }

            var jsonListFile = JsonConvert.DeserializeObject <List <DeviceUserEntry> >(data);

            if (jsonListFile == null)
            {
                jsonListFile = new List <DeviceUserEntry>();
            }

            return(jsonListFile);
        }
예제 #3
0
        public void get_file_path_test()
        {
            const string path = "./";

            Assert.AreEqual(DevicePathService.get_file(path).FullName + ".photon.json", DeviceNoteService.get_file_path(path, false));
        }
예제 #4
0
 public void get_file_path_null_test()
 {
     Assert.AreEqual(null, DeviceNoteService.get_file_path(null, false));
 }