From ce66c5f1b99fe36b5b91e8b59cc75ce8a4e9cba5 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 28 Apr 2015 15:06:59 +0100 Subject: Updated set of unit tests and unit test protos. This commit includes changes to the C#-specific protos, and rebuilt versions of the "stock" protos. The stock protos have been locally updated to have a specific C# namespace, but this is expected to change soon, so hasn't been committed. Four areas are currently not tested: 1) Serialization - we may restore this at some point, possibly optionally. 2) Services - currently nothing is generated for this; will need to see how it interacts with GRPC 3) Fields beginning with _{digit} - see https://github.com/google/protobuf/issues/308 4) Fields with names which conflict with the declaring type in nasty ways - see https://github.com/google/protobuf/issues/309 --- .../MissingFieldAndExtensionTest.cs | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs') diff --git a/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs b/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs index c65cb7f1..b70635d5 100644 --- a/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs +++ b/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs @@ -49,19 +49,19 @@ namespace Google.ProtocolBuffers { const int optionalInt32 = 12345678; TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - builder.SetExtension(UnitTestProtoFile.OptionalInt32Extension, optionalInt32); - builder.AddExtension(UnitTestProtoFile.RepeatedDoubleExtension, 1.1); - builder.AddExtension(UnitTestProtoFile.RepeatedDoubleExtension, 1.2); - builder.AddExtension(UnitTestProtoFile.RepeatedDoubleExtension, 1.3); + builder.SetExtension(Unittest.OptionalInt32Extension, optionalInt32); + builder.AddExtension(Unittest.RepeatedDoubleExtension, 1.1); + builder.AddExtension(Unittest.RepeatedDoubleExtension, 1.2); + builder.AddExtension(Unittest.RepeatedDoubleExtension, 1.3); TestAllExtensions msg = builder.Build(); - Assert.IsTrue(msg.HasExtension(UnitTestProtoFile.OptionalInt32Extension)); - Assert.AreEqual(3, msg.GetExtensionCount(UnitTestProtoFile.RepeatedDoubleExtension)); + Assert.IsTrue(msg.HasExtension(Unittest.OptionalInt32Extension)); + Assert.AreEqual(3, msg.GetExtensionCount(Unittest.RepeatedDoubleExtension)); byte[] bits = msg.ToByteArray(); TestAllExtensions copy = TestAllExtensions.ParseFrom(bits); - Assert.IsFalse(copy.HasExtension(UnitTestProtoFile.OptionalInt32Extension)); - Assert.AreEqual(0, copy.GetExtensionCount(UnitTestProtoFile.RepeatedDoubleExtension)); + Assert.IsFalse(copy.HasExtension(Unittest.OptionalInt32Extension)); + Assert.AreEqual(0, copy.GetExtensionCount(Unittest.RepeatedDoubleExtension)); Assert.AreNotEqual(msg, copy); //Even though copy does not understand the typees they serialize correctly @@ -69,12 +69,12 @@ namespace Google.ProtocolBuffers TestUtil.AssertBytesEqual(bits, copybits); ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnitTestProtoFile.RegisterAllExtensions(registry); + Unittest.RegisterAllExtensions(registry); //Now we can take those copy bits and restore the full message with extensions copy = TestAllExtensions.ParseFrom(copybits, registry); - Assert.IsTrue(copy.HasExtension(UnitTestProtoFile.OptionalInt32Extension)); - Assert.AreEqual(3, copy.GetExtensionCount(UnitTestProtoFile.RepeatedDoubleExtension)); + Assert.IsTrue(copy.HasExtension(Unittest.OptionalInt32Extension)); + Assert.AreEqual(3, copy.GetExtensionCount(Unittest.RepeatedDoubleExtension)); Assert.AreEqual(msg, copy); TestUtil.AssertBytesEqual(bits, copy.ToByteArray()); @@ -85,7 +85,7 @@ namespace Google.ProtocolBuffers //If we replace extension the object this should all continue to work as before copybits = copy.ToBuilder() - .SetExtension(UnitTestProtoFile.OptionalInt32Extension, optionalInt32) + .SetExtension(Unittest.OptionalInt32Extension, optionalInt32) .Build().ToByteArray(); TestUtil.AssertBytesEqual(bits, copybits); } @@ -219,7 +219,7 @@ namespace Google.ProtocolBuffers .AddAddresses( TestInteropPerson.Types.Addresses.CreateBuilder().SetAddress("123 Seseme").SetCity("Wonderland"). SetState("NA").SetZip(12345).Build()) - .SetExtension(UnitTestExtrasFullProtoFile.EmployeeId, + .SetExtension(UnittestExtrasFull.EmployeeId, TestInteropEmployeeId.CreateBuilder().SetNumber("123").Build()) .Build(); Assert.IsTrue(person.IsInitialized); @@ -230,7 +230,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(7, temp.UnknownFields.FieldDictionary.Count); ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnitTestExtrasFullProtoFile.RegisterAllExtensions(registry); + UnittestExtrasFull.RegisterAllExtensions(registry); TestInteropPerson copy = TestInteropPerson.ParseFrom(temp.ToByteArray(), registry); Assert.AreEqual(person, copy); -- cgit v1.2.3