コード例 #1
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 ResourceV1_0(new KeyValuePair<string, object>("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);
        }
コード例 #2
0
        public void DecorateClassSubresourceTest()
        {
            // Create a top and a sub resource.
            var subJson = new JsonDictionary();
            var topJson = new JsonDictionary();
            var topResource = new ResourceV1_0(new KeyValuePair<string, object>("Top", topJson));
            var subResource = new ResourceV1_0(new KeyValuePair<string, object>("Sub", subJson));
            subResource.Parent = topResource;

            var decorator = new StandardResourceNameResourceDecorator();
            var decoratedClass = new CodeTypeDeclaration { Name = "Sub" };
            decorator.DecorateClass(
                subResource, "Sub", decoratedClass, null, ServiceClassName, new IResourceDecorator[0]);

            Assert.AreEqual(1, decoratedClass.Members.Count);
            Assert.IsInstanceOf(typeof(CodeMemberField), decoratedClass.Members[0]);
            var resourceField = (CodeMemberField) decoratedClass.Members[0];
            Assert.AreEqual("Top.Sub", ((CodePrimitiveExpression) resourceField.InitExpression).Value);

            CheckCompile(decoratedClass, false, "Failed To Compile StandardResourceNameResourceDecorator");
        }
コード例 #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 ResourceV1_0(new KeyValuePair<string, object>("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);
        }
コード例 #4
0
ファイル: BaseServiceTest.cs プロジェクト: nick0816/LoggenCSG
        public void TestGetResource()
        {
            var container = CreateV1Service();
            container.Resources.Clear();

            // Create json.
            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 ResourceV1_0(new KeyValuePair<string, object>("Top", topJson));
            var subResource = topResource.Resources["Sub"];
            var grandchildResource = subResource.Resources["Grandchild"];
            container.Resources.Add("Top", topResource);

            // Check the generated full name.
            Assert.AreEqual(container.Methods, BaseService.GetResource(container, "").Methods);
            Assert.AreEqual(topResource, BaseService.GetResource(container, "Top"));
            Assert.AreEqual(subResource, BaseService.GetResource(container, "Top.Sub"));
            Assert.AreEqual(grandchildResource, BaseService.GetResource(container, "Top.Sub.Grandchild"));
        }