public void FileDescriptor_BuildFromByteStrings_DuplicateNames() { var descriptorData = new List <ByteString> { UnittestImportPublicProto3Reflection.Descriptor.SerializedData, UnittestImportPublicProto3Reflection.Descriptor.SerializedData, }; // This will fail due to the same name being used twice Assert.Throws <ArgumentException>(() => FileDescriptor.BuildFromByteStrings(descriptorData)); }
public void FileDescriptor_BuildFromByteStrings_MissingDependency() { var descriptorData = new List <ByteString> { UnittestImportProto3Reflection.Descriptor.SerializedData, UnittestProto3Reflection.Descriptor.SerializedData, }; // This will fail, because we're missing UnittestImportPublicProto3Reflection Assert.Throws <ArgumentException>(() => FileDescriptor.BuildFromByteStrings(descriptorData)); }
public void FileDescriptor_BuildFromByteStrings_IncorrectOrder() { var descriptorData = new List <ByteString> { UnittestProto3Reflection.Descriptor.SerializedData, UnittestImportPublicProto3Reflection.Descriptor.SerializedData, UnittestImportProto3Reflection.Descriptor.SerializedData }; // This will fail, because the dependencies should come first Assert.Throws <ArgumentException>(() => FileDescriptor.BuildFromByteStrings(descriptorData)); }
public void FileDescriptor_BuildFromByteStrings() { // The descriptors have to be supplied in an order such that all the // dependencies come before the descriptors depending on them. var descriptorData = new List <ByteString> { UnittestImportPublicProto3Reflection.Descriptor.SerializedData, UnittestImportProto3Reflection.Descriptor.SerializedData, UnittestProto3Reflection.Descriptor.SerializedData }; var converted = FileDescriptor.BuildFromByteStrings(descriptorData); Assert.AreEqual(3, converted.Count); TestFileDescriptor(converted[2], converted[1], converted[0]); }
public void FieldDescriptor_BuildFromByteStrings() { // The descriptors have to be supplied in an order such that all the // dependencies come before the descriptors depending on them. var descriptorData = new List <ByteString> { UnittestImportPublicProto3Reflection.Descriptor.SerializedData, UnittestImportProto3Reflection.Descriptor.SerializedData, UnittestProto3Reflection.Descriptor.SerializedData }; var converted = FileDescriptor.BuildFromByteStrings(descriptorData); TestFieldDescriptor( converted[2], converted[2].FindTypeByName <MessageDescriptor>("TestAllTypes"), converted[2].FindTypeByName <MessageDescriptor>("ForeignMessage"), converted[1].FindTypeByName <MessageDescriptor>("ImportMessage")); }
public void FileDescriptor_BuildFromByteStrings_WithExtensionRegistry() { var extension = UnittestCustomOptionsProto3Extensions.MessageOpt1; var byteStrings = new[] { DescriptorReflection.Descriptor.Proto.ToByteString(), UnittestCustomOptionsProto3Reflection.Descriptor.Proto.ToByteString() }; var registry = new ExtensionRegistry { extension }; var descriptor = FileDescriptor.BuildFromByteStrings(byteStrings, registry).Last(); var message = descriptor.MessageTypes.Single(t => t.Name == nameof(TestMessageWithCustomOptions)); var extensionValue = message.GetOptions().GetExtension(extension); Assert.AreEqual(-56, extensionValue); }