public Application(IFileManager googleFileManager, IFileManager localFileManager, FileCacheManager fileCacheManager, MemoryCacheManager memoryCacheManager) { GoogleManager = googleFileManager; LocalManager = localFileManager; FileCacheManager = fileCacheManager; MemoryCacheManager = memoryCacheManager; }
public static void Main(string[] args) { Console.OutputEncoding = Encoding.Unicode; try { Console.WriteLine("========== START =========="); var container = new Initializer().RegisterComponents(); var localManager = new LocalFileManager(); var googleManager = new GoogleFileManager(container.Resolve<IGoogleDriveService>()); // TODO: both cache managers should be singletons. I'm a bit worried about possible issues with race conditions when reading/writing, but I don't think this is something serious here var fileCacheManager = new FileCacheManager("filecache.txt"); var memoryCacheManager = new MemoryCacheManager(); var app = new Application(googleManager, localManager, fileCacheManager, memoryCacheManager); app.Start(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
public TreeNavigator(INode googleRoot, INode localRoot, IFileManager googleFileManager, IFileManager localFileManager, FileCacheManager fileCacheManager) { GoogleStack = new Stack<INode>(); LocalStack = new Stack<INode>(); GoogleStack.Push(googleRoot); LocalStack.Push(localRoot); GoogleManager = googleFileManager; LocalManager = localFileManager; FileCacheManager = fileCacheManager; }
public void TestAdd() { var manager = new FileCacheManager("cache"); var root = GetRadomString(); manager.AddOrUpdate(CreateNodeMoq(), root); Assert.IsTrue(File.Exists("cache")); Assert.IsTrue(!string.IsNullOrEmpty(File.ReadAllText("cache"))); //cleanup File.Delete("cache"); }
public void TestUpdate() { var manager = new FileCacheManager("cache"); var root = GetRadomString(); var node1 = new Node {Id = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString()}; manager.AddOrUpdate(node1, root); node1.Name = GetRadomString(); manager.AddOrUpdate(node1, root); var id = manager.GetIdByNameAndParent(node1.Name, root); Assert.AreEqual(node1.Id, id); //cleanup File.Delete("cache"); }
public void TestRead() { var manager = new FileCacheManager("cache"); var root = GetRadomString(); var node1 = new Node {Id = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString()}; var node2 = new Node {Id = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString()}; var child = new Node {Id = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString()}; manager.AddOrUpdate(node1, root); manager.AddOrUpdate(node2, root); manager.AddOrUpdate(child, node1.Id); var fromCache = manager.GetIdByNameAndParent(child.Name, node1.Id); Assert.AreEqual(child.Id, fromCache); //cleanup File.Delete("cache"); }