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");
        }
Exemplo n.º 3
0
 private string GetFromCache(string nodeName, string parentId)
 {
     return(FileCacheManager.GetIdByNameAndParent(nodeName, parentId));
 }