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");
        }
        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 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");
        }
Пример #4
0
 private void AddToCache(INode nodeToBackup, string parentId)
 {
     FileCacheManager.AddOrUpdate(nodeToBackup, parentId);
 }