private void PopulateMethods(TreeNodeCollection c, Resource r) {
   foreach (KeyValuePair<string, Method> kvp in r.Methods) {
     TreeNode m = new TreeNode(kvp.Key);
     PopulateMethod(m.Nodes, kvp.Value);
     c.Add(m);
   }
 }
Exemplo n.º 2
0
        public void FullNameTest()
        {
            var subJson = new JsonDictionary();
            subJson.Add("resources", new JsonDictionary { { "Grandchild", new JsonDictionary() } });
            var topJson = new JsonDictionary();
            topJson.Add("resources", new JsonDictionary { { "Sub", subJson } });

            // Create the resource hierachy.
            var topResource = new Resource(ServiceFactory.Default, "Top", topJson);
            var subResource = topResource.Resources["Sub"];
            var grandchildResource = subResource.Resources["Grandchild"];

            // Check the generated full name.
            Assert.AreEqual("Top", topResource.Path);
            Assert.AreEqual("Top.Sub", subResource.Path);
            Assert.AreEqual("Top.Sub.Grandchild", grandchildResource.Path);
        }
Exemplo n.º 3
0
        public void SubresourceTest()
        {
            var topJson = new JsonDictionary();
            topJson.Add("resources", new JsonDictionary() { { "Sub", new JsonDictionary() } });

            // Create the resource hierachy and confirm results.
            var topResource = new Resource(ServiceFactory.Default, "Top", topJson);
            Assert.IsNotNull(topResource.Resources);
            Assert.AreEqual(1, topResource.Resources.Count);
            Assert.AreEqual("Sub", topResource.Resources["Sub"].Name);
            Assert.AreEqual(topResource, topResource.Resources["Sub"].Parent);
        }