public void can_add_and_save_and_load_again() { using (var fs = new FileSystemTester()) { var set = new FileMetadataCache(); var store = new JsonStore(); var filename = "file-change-set.json"; var file = fs.Touch("file.txt"); set.Add(file); fs.Write(filename, s => store.Save(s, set)); var loadedSet = fs.Read(filename, store.Load<FileMetadataCache>); Assert.IsNotNull(loadedSet); Assert.AreEqual(1, loadedSet.Files.Count); var fileinfo = loadedSet.Files.ElementAt(0); Assert.AreEqual(file.Name, Path.GetFileName(fileinfo.FilePath)); Assert.AreEqual(file.Length, fileinfo.Length); Assert.AreEqual(file.LastWriteTimeUtc, fileinfo.LastWriteTimeUtc); } }
public void can_save_and_load() { using(var fs = new FileSystemTester()) { var set = new FileMetadataCache(); var store = new JsonStore(); var filename = "file-change-set.json"; fs.Write(filename, s => store.Save(s, set)); fs.Read(filename, store.Load<FileMetadataCache>); } }
public void modifiying_file_in_set_causes_has_changes_to_return_true() { using (var fs = new FileSystemTester()) { var set = new FileMetadataCache(); var store = new JsonStore(); var filename = "file-change-set.json"; var file = fs.Touch("file.txt"); set.Add(file); fs.Write(filename, s => store.Save(s, set)); var loadedSet = fs.Read(filename, store.Load<FileMetadataCache>); Assert.IsFalse(loadedSet.HasChanges()); fs.Touch(file.FullName); Assert.IsTrue(loadedSet.HasChanges()); } }
public void can_add_item() { var set = new FileMetadataCache(); set.Add("file.txt", DateTime.UtcNow, 1000); }
private void CreateCache(DroneConfig config) { var cache = new FileMetadataCache(); cache.Add(new FileInfo(config.FilePath)); foreach(var source in this.ResolveSourceFiles(config.SourceFiles, config.DirPath)) cache.Add(new FileInfo(source)); foreach(var reference in this.ResolveReferenceFiles(config.ReferenceFiles, config.DirPath)) cache.Add(new FileInfo(reference)); this.store.Save(this.GetCacheFileName(config), cache); }