public void GenerateRequestClassesTest()
        {
            var decorator = new CountingRequestDecorator();
            var generator = new RequestClassGenerator(new IRequestDecorator[] { decorator });
            var decl      = new CodeTypeDeclaration();

            // Create a test resource.
            var resource = new MockResource();

            resource.Methods.Add("MethodA", new MockMethod()
            {
                Name = "MethodA"
            });
            resource.Methods.Add("MethodB", new MockMethod()
            {
                Name = "MethodB"
            });

            // Run the generator
            CodeTypeMemberCollection collection = generator.GenerateRequestClasses(decl, resource);

            Assert.AreEqual(2, decorator.TimesCalled);
            Assert.AreEqual(2, collection.Count);
            Assert.IsInstanceOf <CodeTypeDeclaration>(collection[0]);
            Assert.IsInstanceOf <CodeTypeDeclaration>(collection[1]);
            CollectionAssert.AreEqual(
                new[]
            {
                string.Format(RequestClassGenerator.RequestClassNamingScheme, "MethodA"),
                string.Format(RequestClassGenerator.RequestClassNamingScheme, "MethodB"),
            },
                from CodeTypeMember m in collection select m.Name);
        }
        public void GenerateRequestClassesTest()
        {
            var decorator = new CountingRequestDecorator();
            var generator = new RequestClassGenerator(new IRequestDecorator[] { decorator });
            var decl = new CodeTypeDeclaration();

            // Create a test resource.
            var resource = new MockResource();
            resource.Methods.Add("MethodA", new MockMethod() { Name = "MethodA"});
            resource.Methods.Add("MethodB", new MockMethod() { Name = "MethodB"});

            // Run the generator
            CodeTypeMemberCollection collection = generator.GenerateRequestClasses(decl, resource);
            Assert.AreEqual(2, decorator.TimesCalled);
            Assert.AreEqual(2, collection.Count);
            Assert.IsInstanceOf<CodeTypeDeclaration>(collection[0]);
            Assert.IsInstanceOf<CodeTypeDeclaration>(collection[1]);
            CollectionAssert.AreEqual(
                new[]
                    {
                        string.Format(RequestClassGenerator.RequestClassNamingScheme, "MethodA"),
                        string.Format(RequestClassGenerator.RequestClassNamingScheme, "MethodB"),
                    },
                from CodeTypeMember m in collection select m.Name);
        } 
        public void GenerateRequestClassTest()
        {
            var decorator = new CountingRequestDecorator();
            var generator = new RequestClassGenerator(new IRequestDecorator[] { decorator });
            var decl      = new CodeTypeDeclaration();

            // Create a test resource.
            var        resource = new MockResource();
            MockMethod method   = new MockMethod()
            {
                Name = "MethodA"
            };

            resource.Methods.Add("MethodA", method);

            // Run the generator
            CodeTypeDeclaration newClass = generator.GenerateRequestClass(resource, method, decl, new string[0]);

            Assert.IsNotNull(newClass);
            Assert.AreEqual(1, decorator.TimesCalled);
            Assert.AreEqual(0, newClass.Members.Count);
        }
        public void GenerateRequestClassTest()
        {
            var decorator = new CountingRequestDecorator();
            var generator = new RequestClassGenerator(new IRequestDecorator[] { decorator });
            var decl = new CodeTypeDeclaration();

            // Create a test resource.
            var resource = new MockResource();
            MockMethod method = new MockMethod() { Name = "MethodA" };
            resource.Methods.Add("MethodA", method);

            // Run the generator
            CodeTypeDeclaration newClass = generator.GenerateRequestClass(resource, method, decl, new string[0]);
            Assert.IsNotNull(newClass);
            Assert.AreEqual(1, decorator.TimesCalled);
            Assert.AreEqual(0, newClass.Members.Count);
        }