def test_add_method(self):
        helper = IdlTestingHelper()
        builder = InterfaceContextBuilder(
            'test',
            TypeResolver(
                helper.make_stub_interfaces_info({
                    'foo': 'path_to_foo',
                    'bar': 'path_to_bar',
                    'garply': 'path_to_garply',
                })))

        operation = helper.make_stub_idl_operation('foo', 'bar')
        builder.add_operation(operation)
        self.assertEqual(
            {
                'code_generator': 'test',
                'cpp_includes': set(['path_to_bar']),
                'methods': [{
                    'arguments': [],
                    'name': 'Foo',
                    'type': 'bar'
                }],
            }, builder.build())

        operation = helper.make_stub_idl_operation('quux', 'garply')
        operation.arguments = [
            helper.make_stub_idl_argument('barBaz', IdlType('qux'))
        ]
        builder.add_operation(operation)
        self.assertEqual(
            {
                'code_generator':
                'test',
                'cpp_includes':
                set(['path_to_bar', 'path_to_garply']),
                'methods': [{
                    'arguments': [],
                    'name': 'Foo',
                    'type': 'bar'
                }, {
                    'arguments': [{
                        'name': 'bar_baz',
                        'type': 'qux'
                    }],
                    'name': 'Quux',
                    'type': 'garply'
                }],
            }, builder.build())
    def test_add_method(self):
        helper = IdlTestingHelper()
        builder = InterfaceContextBuilder(
            'test', TypeResolver(helper.make_stub_interfaces_info({
                'foo': 'path_to_foo',
                'bar': 'path_to_bar',
                'garply': 'path_to_garply',
            })))

        operation = helper.make_stub_idl_operation('foo', 'bar')
        builder.add_operation(operation)
        self.assertEqual({
            'code_generator': 'test',
            'cpp_includes': set(['path_to_bar']),
            'methods': [{
                'arguments': [],
                'name': 'Foo',
                'type': 'bar'
            }],
        }, builder.build())

        operation = helper.make_stub_idl_operation('quux', 'garply')
        operation.arguments = [
            helper.make_stub_idl_argument('barBaz', IdlType('qux'))
        ]
        builder.add_operation(operation)
        self.assertEqual({
            'code_generator': 'test',
            'cpp_includes': set(['path_to_bar', 'path_to_garply']),
            'methods': [
                {
                    'arguments': [],
                    'name': 'Foo',
                    'type': 'bar'
                },
                {
                    'arguments': [
                        {'name': 'bar_baz', 'type': 'qux'}
                    ],
                    'name': 'Quux',
                    'type': 'garply'
                }
            ],
        }, builder.build())
    def test_add_method(self):
        helper = IdlTestingHelper()
        builder = InterfaceContextBuilder(
            'test',
            TypeResolver(
                helper.make_stub_interfaces_info({
                    'foo': 'path_to_foo',
                    'bar': 'path_to_bar'
                })))

        operation = helper.make_stub_idl_operation('foo', 'bar')
        builder.add_operation(operation)
        self.assertEqual(
            {
                'code_generator': 'test',
                'cpp_includes': set(['path_to_bar']),
                'methods': [{
                    'name': 'foo',
                    'return_type': 'bar'
                }],
            }, builder.build())