public void DecorateClassSubresourceTest()
        {
            // Create a top and a sub resource.
            var subJson     = new JsonDictionary();
            var topJson     = new JsonDictionary();
            var factory     = ServiceFactory.Get(DiscoveryVersion.Version_1_0);
            var topResource = factory.CreateResource("Top", topJson);
            var subResource = factory.CreateResource("Sub", subJson);

            ((Resource)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");
        }
        public void DecorateClassTest()
        {
            var decorator      = new StandardResourceNameResourceDecorator();
            var decoratedClass = CreateDecoratedResourceClass(decorator);

            Assert.AreEqual(1, decoratedClass.Members.Count);
            Assert.IsInstanceOf(typeof(CodeMemberField), decoratedClass.Members[0]);
            Assert.AreEqual(ResourceBaseGenerator.ResourceNameConst, decoratedClass.Members[0].Name);

            CheckCompile(decoratedClass, false, "Failed To Compile StandardResourceNameResourceDecorator");
        }
        public void CreateResourceNameConstTest()
        {
            var             decorator = new StandardResourceNameResourceDecorator();
            CodeMemberField codeField = decorator.CreateResourceNameConst("TestResourceName");

            Assert.AreEqual(ResourceBaseGenerator.ResourceNameConst, codeField.Name);
            Assert.AreEqual(typeof(string).FullName, codeField.Type.BaseType);
            Assert.IsInstanceOf(typeof(CodePrimitiveExpression), codeField.InitExpression);

            var initExpression = (CodePrimitiveExpression)codeField.InitExpression;

            Assert.AreEqual("TestResourceName", initExpression.Value);
        }