public void TestCreateParametersProprety()
        {
            var decorator = new BaseClientServiceAbstractPropertiesDecorator();
            var service   = CreateService();

            var propertyCollection = decorator.CreateServiceParametersProperty();

            Assert.AreEqual(2, propertyCollection.Count);

            Assert.IsInstanceOf(typeof(CodeMemberField), propertyCollection[0]);
            Assert.IsInstanceOf(typeof(CodeMemberProperty), propertyCollection[1]);

            CodeMemberField    field    = (CodeMemberField)propertyCollection[0];
            CodeMemberProperty property = (CodeMemberProperty)propertyCollection[1];

            Assert.IsTrue(field.Name.Equals("_serviceParameters"));
            Assert.AreEqual("ServiceParameters", property.Name);

            Assert.AreEqual(2, property.Type.TypeArguments.Count);
            // read the following to understand the next assert
            // http://msdn.microsoft.com/en-us/library/system.codedom.codetypereference.basetype(v=vs.90).aspx
            Assert.AreEqual("System.Collections.Generic.IDictionary`2", property.Type.BaseType);

            Assert.AreEqual("System.String", property.Type.TypeArguments[0].BaseType);
            Assert.AreEqual("Google.Apis.Discovery.IParameter", property.Type.TypeArguments[1].BaseType);
        }
        public void TestCreatePathField()
        {
            var decorator       = new BaseClientServiceAbstractPropertiesDecorator();
            var codeMemberField = decorator.CreateBasePathProperty(CreateService());

            Assert.AreEqual("BasePath", codeMemberField.Name);
            Assert.AreEqual(BasePath, GetReturnPrimitiveValue(codeMemberField));
        }
        public void DecorateClass()
        {
            var decorator = new BaseClientServiceAbstractPropertiesDecorator();
            var service   = CreateService();

            var codeType = new CodeTypeDeclaration("TestClass");

            decorator.DecorateClass(service, codeType);

            codeType.BaseTypes.Add(new CodeTypeReference(typeof(MockBaseClientServiceAbstractPropertiesDecorator)));
            CheckCompile(codeType, false, "Failed To Compile result from StandardServiceFieldResourceDecorator",
                         new[] { new CodeNamespaceImport("Google.Apis.Testing") },
                         new[] { typeof(MockBaseClientServiceAbstractPropertiesDecorator) });
        }
        public void TestCreateFeaturesList()
        {
            var decorator = new BaseClientServiceAbstractPropertiesDecorator();
            var property  = decorator.CreateFeaturesProperty(CreateService());

            Assert.AreEqual("Features", property.Name);

            Assert.That(property.GetStatements.Count, Is.EqualTo(1));
            Assert.That(property.GetStatements[0], Is.TypeOf(typeof(CodeMethodReturnStatement)));
            var returnStatement = property.GetStatements[0] as CodeMethodReturnStatement;

            Assert.That(returnStatement.Expression, Is.TypeOf(typeof(CodeArrayCreateExpression)));
            var arrayExpression = returnStatement.Expression as CodeArrayCreateExpression;

            Assert.That(arrayExpression.CreateType.BaseType, Is.EqualTo("System.string"));
            Assert.That(arrayExpression.Initializers.Count, Is.EqualTo(4));
        }