public void ServiceDescriptor()
        {
            ServiceDescriptor service = TestGenericService.Descriptor;

            Assert.AreEqual("TestGenericService", service.Name);
            Assert.AreEqual("protobuf_unittest.TestGenericService", service.FullName);
            Assert.AreEqual(UnitTestGenericServices.Descriptor, service.File);

            Assert.AreEqual(2, service.Methods.Count);

            MethodDescriptor fooMethod = service.Methods[0];

            Assert.AreEqual("Foo", fooMethod.Name);
            Assert.AreEqual(FooRequest.Descriptor, fooMethod.InputType);
            Assert.AreEqual(FooResponse.Descriptor, fooMethod.OutputType);
            Assert.AreEqual(fooMethod, service.FindMethodByName("Foo"));

            MethodDescriptor barMethod = service.Methods[1];

            Assert.AreEqual("Bar", barMethod.Name);
            Assert.AreEqual(BarRequest.Descriptor, barMethod.InputType);
            Assert.AreEqual(BarResponse.Descriptor, barMethod.OutputType);
            Assert.AreEqual(barMethod, service.FindMethodByName("Bar"));

            Assert.IsNull(service.FindMethodByName("NoSuchMethod"));

            for (int i = 0; i < service.Methods.Count; i++)
            {
                Assert.AreEqual(i, service.Methods[i].Index);
            }
        }
        public void CustomOptions()
        {
            MessageDescriptor descriptor = TestMessageWithCustomOptions.Descriptor;

            Assert.IsTrue(descriptor.Options.HasExtension(UnitTestCustomOptionsProtoFile.MessageOpt1));
            Assert.AreEqual(-56, descriptor.Options.GetExtension(UnitTestCustomOptionsProtoFile.MessageOpt1));


            FieldDescriptor field = descriptor.FindFieldByName("field1");

            Assert.IsNotNull(field);

            Assert.IsTrue(field.Options.HasExtension(UnitTestCustomOptionsProtoFile.FieldOpt1));
            Assert.AreEqual(8765432109uL, field.Options.GetExtension(UnitTestCustomOptionsProtoFile.FieldOpt1));

            // TODO: Write out enum descriptors

            /*
             * EnumDescriptor enumType = TestMessageWithCustomOptions.Types.
             * UnittestCustomOptions.TestMessageWithCustomOptions.AnEnum.getDescriptor();
             *
             * Assert.IsTrue(
             * enumType.getOptions().hasExtension(UnittestCustomOptions.enumOpt1));
             * Assert.AreEqual(Integer.valueOf(-789),
             * enumType.getOptions().getExtension(UnittestCustomOptions.enumOpt1));
             */

            ServiceDescriptor service = TestGenericServiceWithCustomOptions.Descriptor;

            Assert.IsTrue(service.Options.HasExtension(UnitTestCustomOptionsProtoFile.ServiceOpt1));
            Assert.AreEqual(-9876543210L, service.Options.GetExtension(UnitTestCustomOptionsProtoFile.ServiceOpt1));

            MethodDescriptor method = service.FindMethodByName("Foo");

            Assert.IsNotNull(method);

            Assert.IsTrue(method.Options.HasExtension(UnitTestCustomOptionsProtoFile.MethodOpt1));
            Assert.AreEqual(MethodOpt1.METHODOPT1_VAL2,
                            method.Options.GetExtension(UnitTestCustomOptionsProtoFile.MethodOpt1));
        }