From 3980cf9df1ca9c66718f1fe9817011134f87bbcd Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 30 Jul 2015 13:35:42 +0100 Subject: Prohibit null values for string/bytes fields in generated code. --- csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'csharp/src/Google.Protobuf.Test') diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs index dfaac48c..140b878c 100644 --- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs +++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -111,6 +111,16 @@ namespace Google.Protobuf Assert.IsNull(message.OneofNestedMessage); } + [Test] + public void NullStringAndBytesRejected() + { + var message = new TestAllTypes(); + Assert.Throws(() => message.SingleString = null); + Assert.Throws(() => message.OneofString = null); + Assert.Throws(() => message.SingleBytes = null); + Assert.Throws(() => message.OneofBytes = null); + } + [Test] public void RoundTrip_Empty() { -- cgit v1.2.3