From 964627ece023577f252b888c9a9d6d9c2c563fc3 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Sat, 24 Oct 2015 06:45:20 +0100 Subject: Include the oneof-case in equality and hash code generated code. The included C# test will fail until the regenerated code is used, which is in the next commit. --- csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs') diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs index 575d4586..1163f524 100644 --- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs +++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -565,6 +565,16 @@ namespace Google.Protobuf Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); } + [Test] + public void Oneof_DefaultValuesNotEqual() + { + var message1 = new TestAllTypes { OneofString = "" }; + var message2 = new TestAllTypes { OneofUint32 = 0 }; + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message1.OneofFieldCase); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + Assert.AreNotEqual(message1, message2); + } + [Test] public void OneofSerialization_NonDefaultValue() { -- cgit v1.2.3