コード例 #1
0
 public Application(IFileManager googleFileManager, IFileManager localFileManager, FileCacheManager fileCacheManager, MemoryCacheManager memoryCacheManager)
 {
     GoogleManager = googleFileManager;
     LocalManager = localFileManager;
     FileCacheManager = fileCacheManager;
     MemoryCacheManager = memoryCacheManager;
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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;
 }
コード例 #4
0
        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");
        }
コード例 #5
0
        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");
        }
コード例 #6
0
        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");
        }